Expand my Community achievements bar.

SOLVED

Delivery API and global mbox

Avatar

Level 3

Hello!

I need to implement the Delivery API using global mbox.

It seems that is not possible since I am receiving this error message as a response:

"status": 400,
"message": "Errors: field - [execute.mboxes] - global mbox is not allowed in mboxes.;"

I found that another user fixed this by using "['execute']['pageLoad']" instead of "['execute']['mboxes']", however I don't understand how to implement this change since the API docs are not very clear.

In short, I need to get all the activities that are using the global mbox.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 3

We finally found a solution to this issue. 

The following element was missing from the request:

$data['context']['address']['url'] = [URL]

Thank you @Rajneesh_Gautam_ for your support, kind attention, and professionalism.

View solution in original post

19 Replies

Avatar

Level 3

I have also tried to use "__view__" as the mbox name (since the global mbox is the "__view__" scope according to this docs) but it did not work.

Avatar

Community Advisor

hi @PedroFi  - you are right, the documentation requires updates.

 

In the meantime, here's how you can use global-mbox. You need not mention the name of the mbox. Hope it helps

 "execute": {
       "pageLoad" : {
       "parameters": {
           "a": 1,
           "b": 2
         }
       }
       
     }

 

Avatar

Level 3

Thanks, @Rajneesh_Gautam_ , but it did not work.

This is what my PHP request looks like:

Array
(
    [headers] => Array
        (
            [Content-Type] => application/json
            [cache-control] => no-cache
        )

    [json] => Array
        (
            [context] => Array
                (
                    [channel] => web
                )

            [property] => Array
                (
                    [token] => TOKEN
                )

            [execute] => Array
                (
                    [pageLoad] => Array
                        (
                            [parameters] => Array
                                (
                                    [a] => 1
                                    [b] => 2
                                )

                        )

                )

            [experienceCloud] => Array
                (
                    [analytics] => Array
                        (
                            [logging] => client_side
                            [supplementalDataId] => DATA_ID
                            [trackingServer] => SERVER
                        )

                )

            [qaMode] => Array
                (
                    [token] => TOKEN
                    [listedActivitiesOnly] => true
                    [evaluateAsTrueAudienceIds] => Array
                        (
                            [0] => ID
                        )

                    [previewIndexes] => Array
                        (
                            [0] => Array
                                (
                                    [activityIndex] => 1
                                    [experienceIndex] => 1
                                )

                        )

                )

        )

)

 

Avatar

Community Advisor

Hi @PedroFi - looks like you are send pageLoad as array. It should be a single object.

Avatar

Level 3

Unless I'm wrong, that's the way to implement it using PHP. 

If my assumption is incorrect, would you mind showing me how to turn it into a single object?

Avatar

Community Advisor

Hi @PedroFi - not a PHP expert myself, is it possible to share the request body this code is generating

Avatar

Level 3

The request body is the same that I shared in my previous comment: https://experienceleaguecommunities.adobe.com/t5/adobe-target-questions/delivery-api-and-global-mbox...

 

And this is the response, as you can see "pageLoad" is empty:

Array
(
    [status] => 200
    [requestId] => ID
    [client] => CLIENT
    [id] => Array
        (
            [tntId] => TNT_ID
        )

    [edgeHost] => HOST
    [telemetryServerToken] => TOKEN
    [execute] => Array
        (
            [pageLoad] => Array
                (
                )

        )

)

 

Avatar

Community Advisor

Hello @PedroFi  - used an online tool to convert JSON object for the request-body, that works for me, into a PHP array and here's the result. Please check 

 

array(
"context" => array(
"channel" => "web"
),
"id" => array(
"tntId" => "-------"
),
"experienceCloud" => array(
"analytics" => array(
"logging" => "client_side"
)
),
"execute" => array(
"pageLoad" => array(
"parameters" => array(
"a" => 1,
"b" => 2
)
)
)
);

Avatar

Level 3

Thanks @Rajneesh_Gautam_ 

The PHP array you shared looks the same as that I was already using.

What do you mean by "that works for me"? Are you able to get the list of activities with that configuration?

Avatar

Community Advisor

Hi @PedroFi  - I am using JavaScript's Fetch method to pass that payload to Adobe Target using Delivery API and thats working for me. If you need a quick demo, I can jump on a quick call and show it to you

 

Regards

Rajneesh

Avatar

Level 3

Would you mind sending me the JS code you're using, @Rajneesh_Gautam_ ?

I would like to compare it with my PHP code and see what's wrong.

Keep in mind that I'm trying to implement the Delivery API on the server side.

Avatar

Community Advisor

Hi @PedroFi  - I coded a quick PHP program using cURL which successfully returns content from Adobe Target activity based on global mbox. Please find the code below. 

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<<your-client-code>>.tt.omtrdc.net/rest/v1/delivery?client=<<your-client-code>>&sessionId=aa1f8a7be8234997aa7e5f12ce863d62',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>' {
     "context":{
       "channel":"web"
     },
     "id": {
         "tntId": "005d07c430b740f1b715e93a595be201.37_0"
     },
     "experienceCloud" : {     
       "analytics": {
         "logging": "client_side"
       }
     },
     "execute": {
       "pageLoad" : 
       {
         "parameters": {
           "a": 1,
           "b": 2
         }
       }
       
     }

   }
',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

  

Avatar

Level 1

Thanks, @Rajneesh_Gautam_ 

Can I ask you what you mean by "successfully returns content"? Does it mean that you're getting a list of activities?

On my side, using the PHP code you provided, I am still getting the same result as mentioned here: no list of activities and empty value for [execute][pageLoad]

Avatar

Level 3

Thanks, @Rajneesh_Gautam_ 

Can I ask you what you mean by "successfully returns content"? Does it mean that you're getting a list of activities?

On my side, using the PHP code you provided, I am still getting the same result as mentioned here: no list of activities and empty value for [execute][pageLoad]

Avatar

Community Advisor

hi @PedroFi @user38511 , of course!  The code responds with the content of all activities visitor qualifies for, along with response tokens. 

 

The original question was how we can use global-mbox with Delivery API - given you are now getting 200 in the response, I am assuming that issue is resolved?

 

Now for the response being empty - there could be multiple reasons. The most usual suspect is that the visitor does not qualify for the activity you are testing. To test it, you may take configure an activity which is live for everyone and does not make any change i.e. returns the default content. This way you will be able to ensure that your basic setup works. Then you may investigate issues related to audience qualification.

 

Let me know how it goes

 

Regards

Rajneesh

 

Avatar

Level 3

Thank you again, @Rajneesh_Gautam_ 

As you can see in my previous message, I am using the QA mode since I have no active activity at this moment. I already tested it using a non-global mbox and it worked correctly.

Could the problem be related to the fact that the QA mode URLs only reference one activity, so the global mbox has no effect?

Avatar

Community Advisor

hi @PedroFi  - yes I saw that you are using QA mode. Since QA-URL is applicable to just one activity (I am not aware of any way to apply same QA URL to multiple activities), retrieving that activity using global-mbox or without global-mbox should not matter.

 

In my view, I thought you are trying to understand how to fetch content of more than  one activities at the same time, if a visitor qualifies for all of these. Using target-global-mbox provides a scalable solution in this case as you will not need to update the server-side code with the names of local-mboxes.

 

Before going live, you'll use QA-mode to test whether you are getting qualified for a "single" activity and that the content is retrieved by the server-side component. However, when you'll go live - Adobe Target will send you code of all activities that visitor qualifies for.

 

Even if your activity is using a global-mbox and as long as you are using the QA-token for that specific activity - you should get still retrieve the content back. 

 

Quick question: I see that you have used "evaluateAsTrueAudienceIds" under qaMode. Did that work for you when you tested with a local mbox? 

Avatar

Level 3

Hello again @Rajneesh_Gautam_:

"evaluateAsTrueAudienceIds" under qaMode works for me when I test with a local mbox. However, global mbox is still not working on the QA mode. What am I possibly missing?

 

Could you also explain the meaning of these parameters? What do "a=1" and "b=2" represent exactly?

"execute": {
       "pageLoad" : 
       {
         "parameters": {
           "a": 1,
           "b": 2
         }
       }

Avatar

Correct answer by
Level 3

We finally found a solution to this issue. 

The following element was missing from the request:

$data['context']['address']['url'] = [URL]

Thank you @Rajneesh_Gautam_ for your support, kind attention, and professionalism.