Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

how to return json response with adobe.target.getOffer

xiaog92197055
Level 1
Level 1

I created a json type offer and want target to return that. However, when I try the following code, response is blank. I couldn’t find any code example on adobe website specifically about return json response. Can you double check whether I missed something below or if you can point me to a code example/documentation with json response call? By the way, the following way works fine if it is html offer.

 

adobe.target.getOffer({  

  "mbox": "mboxname",

  "params": {

 "profile.language": "en"

  },

  "success": function(offer) {

console.log(offer);

alert(offer);         

        adobe.target.applyOffer( { 

           "mbox": "mboxname",

           "offer": offer

 

        } );

  },  

  "error": function(status, error) {          

      console.log('Error', status, error);

  }

});

1 Accepted Solution
skandg43264764
Correct answer by
Level 4
Level 4

@xiaog92197055 

Kindly marked this post as answered if the suggested solution did help you in achieving your result.

 

View solution in original post

8 Replies
skandg43264764
Level 4
Level 4

@xiaog92197055 

Code looks fine to me. I will check the code by executing at my end and will let you know.

Meanwhile, Can you share the screenshot from the browser console showing what are you getting in 'offer' via console.log(offer) function

xiaog92197055
Level 1
Level 1
actually console.log(offer) doesn't print offer in console. but alert(offer) works. Replace the mbox name in my code with mbox you use. you will see the alert pop up. I don't see an option here to upload screenshot.
skandg43264764
Level 4
Level 4
Yes you need mention the mbox name on which you have created the activity.
skandg43264764
Level 4
Level 4

Yes you need to mention the mbox name on which you have created the activity.

Yes you need to create a json offer which you need to attach to your formbased activity.

You can create a Json offer as 

Target UI -> On top menu 'Offers' -> code offers -> create -> json offer -> save

Then attach this to your formbased activity and save the activity.

Now execute your getoffer() for mbox on which activity is created and json offer is attached, you should be able to see the json offer content.

 

Hope this helps !

 

 

 

xiaog92197055
Level 1
Level 1
I had completed all the steps you mentioned and don't see json response. Don't I need to setJson somewhere in getoffer? do you see json response returned? if yes, can you share sample code?
skandg43264764
Level 4
Level 4

I am able to get the JSON response, using getoffer() as :

adobe.target.getOffer({
mbox: "ClicksImageButtonMbox",
success: function(actions) {
console.log('Success', actions);
},
error: function(status, error) {
console.log('Error', status, error);
}
});
Refer below screenshot :
FormBasedActivity_GetOFFER-JSON.pngFormBasedActivity_JSONOFFER_attached.png

Hope this will help you !

skandg43264764
Correct answer by
Level 4
Level 4

@xiaog92197055 

Kindly marked this post as answered if the suggested solution did help you in achieving your result.

 

View solution in original post