Accessing Recommendation Data through Target APIs

Runal_Trivedi 03-07-2017

Hi,

We have a requirement where we have to access the recommendation data through API, and show the each Recommended Item at specific location in result set on the landing page. Consider as in search results, you are injecting recommended items at specific locations.

For this I have a recommendation activity running on a page that return me the result set, when I use the standard replace content option in activity settings.

I tried to access the same activity on that page using the standard Target APIs. For e.g.:

I referred documentation as mentioned by Adobe on following page - Delivery

Steps I followed: I Used POSTMAN (Chrome addon) to test this.

POST URL - http://clientid.tt.omtrdc.net/rest/v1/mbox/12223434537?client=clientid

Request JSON:

{

  "mbox" : "target-global-mbox", 

  "requestLocation" : {

    "pageURL" : "http://www.abc.com/test/parentpage/child-page/some-targeted-page", 

    "host" : "www.abc.com",

    "impressionId" : "1"

  },

  "mboxParameters" : {

    "screenHeight" : "900",

    "screenWidth" : "1440",

    "browserWidth" : "1440",

    "browserHeight" : "278",

     some other parameters...

  }

}

But when I try to hit above request in POSTMAN, I always get below response:

Response:

{

    "status": 501,

    "message": "Unable to serve visual offers through server-side calls"

}

To debug further, I tried to change the call to non-recommendation activity type, like a standard A/B testing. But that too gives me the same response.

I have following questions related to above requirement:

1. Is it possible to programmatically access the Recommendation result set? If yes, then if someone can please provide any pointers?

2. What is wrong with above request/response. I am following the github example as listed here - Lesson 1: The Tools of the Trade · Adobe-Marketing-Cloud/target-api-examples Wiki · GitHub

  •      Only change I have made to my request is; I am not generated thirdpartyID, as I don't have a need to track this as a user behavior, and I just need to provide recommendations, in a scattered way on some landing page.

Please let me know if anyone has tried such thing, and what is the ideal way to achieve it.

Thanks in Advance!

Runal

Accepted Solutions (1)

Accepted Solutions (1)

Jon_Tehero
Employee
18-10-2017

Hmm, that shouldn't be happening. I just confirmed that I am able to append the pageURL, host and impressionId to an existing server-side request that I am using in an activity and everything worked for me.

I recommend that you create a brand new Design (from scratch) from withing the Design library. To do this, go to https://{{your-tenant-name-here}}.marketing.adobe.com/content/mac/{{your-tenant-name-here}}/target/products.html#designs and BEFORE you save it, ensure that it is NOT an HTML-based Design.

After you've done that, go ahead and update your form-based activity to use that Design.

If you still have a problem after that, please submit a bug with all the details to our customer care team (tt-support@adobe.com) so we can investigate.

Answers (5)

Answers (5)

mikem123456 15-07-2019

I just wanted to mention something that happened to me. I didn't realize that I was using an mbox which was associated with other (HTML) type offers. The first thing you'll want to do if this is happening is make sure that the mbox that you're using for the api calls is unique and not associated with other HTML offers.

Hopefully that helps someone.

Runal_Trivedi 18-10-2017

Hi Jon,

This is particularly happening when we provide mboxParameters in the API call. My Ultimate goal was to run the recommendations filter criteria based on the mboxParameters passed in the API call. In below example, I wanted to filter the recommended results that matched category "Action". But the moment I provide mboxParameters in the API call, it starts throwing the 501 error code, and starts complaining as if the recommendation activity was visual offer.

"mboxParameters" : {

    "categoryId" : "Action"

  }

Can you try it once and see if things work fine for you using mboxParameters? if so, then I will log the day-care tickets.

Documentation doesn't mention any API level restriction in using mboxParameters in API calls, so I assume it will result into a product bug. But, please, it will be great, if you can confirm once.

Regards,

Runal

Runal_Trivedi 17-10-2017

Hi Jon,

Thats exactly the way we did it. But there was another quick thing I wanted to confirm, if you know.

When I try to pass target params in the API, I run into error the same visual form error:

Request:

{

  "mbox" : "target-global-mbox",

  "thirdPartyId" : "1313131231",

  "requestLocation" : {

    "pageURL" : "https://something.com/abc/xyz/#datapullbycatgid", 

    "host" : "something.com",

    "impressionId" : "1"

  },

  "mboxParameters" : {

    "categoryId" : "Action"

  }

}

Response:

{

    "status": 501,

    "message": "Unable to serve visual offers through server-side calls"

}

Not sure why it starts considering the form based activity to a visual offer activity, with the params, if I remove the mboxparameters from the request, then everything works fine.

Have you faced it before? is there a way to overcome this?

Regards,

Runal

Jon_Tehero
Employee
17-10-2017

Hi Runal,

Recommendations can be delivered via API as long as it is configured via the form-based editor (not the Visual Experience Composer). When creating the activity, make sure the turn off the "HTML Design" toggle so that the output isn't wrapped in <div> tags. This will allow for a clean JSON or raw text output.

1326598_pastedImage_0.png