-
Notifications
You must be signed in to change notification settings - Fork 1
Node.js TargetSDK:ERROR_GET_OFFER_BY_ID #56
Description
While we are working on Adobe IO to get/update the offer in Adobe Target through Adobe IO Target library
Expected Behaviour
When calling getOfferById() function, the following error occurred:
Actual Behaviour
we are getting the below errors.
[TargetSDK: ERROR_GET_OFFER_BY_ID] Error: Not Acceptable

Reproduce Scenario (including but not limited to)
Can be easily reproduced in the following steps
Steps to Reproduce
Download the zip file and keep the js file in a folder. (see attached targetInit.zip)
targetInit.zip
You will need to replace the access token to a valid access token in the targetInit.js file, the problem can be reproduced with any Target company with json offers in the Offer library.
Open a command prompt in the folder the targetInit.js file exists. Run the below command.
npm install @adobe/aio-lib-target
Post that run the below command.
node targetInit.js
Replicate the issue with the above steps.
We are trying to give solution using Adobe IO serverless architecture to update the Target Activity/Offers through Adobe IO Target library.
Platform and Version
Node.js latest version
Sample Code that illustrates the problem
see targetInit.js
const offer = await targetClient.getOfferById(offerID)
Logs taken while reproducing problem
It seems the root cause is the get Offer Content call. which fails with a 406.
curl --location --request GET 'https://mc.adobe.io/tatadigital/target/offers/content/458563'
--header 'Authorization: Bearer '
--header 'x-api-key: '
Returns
{
"httpStatus": 406,
"requestId": "KsYtjLDzfFsvvcG9DiYAmPMibqnHEC3I",
"requestTime": "2021-06-11T00:12:22.634272Z",
"errors": [
{
"errorCode": "Unsupported.Feature",
"message": "Unsupported offer type. The only supported type is: content",
"meta": {}
}
]
}
All the offers returned when listing the offers are of Type = json
Changing the URL above to https://mc.adobe.io/tatadigital/target/offers/json/458563'
returns
{
"id": 458563,
"name": "/birthday_offers/experiences/0/pages/0/zones/0/1623150537848",
"content":
{ "ShowOffers": "true", "count": "5" }
,
"modifiedAt": "2021-06-08T12:26:30Z"
}
The JAVAScript code needs to examine the type of the offer and make the appropriate backend API call.
The Swagger spec seems to have support for content but not for a variable to take the type.
There seems to be a discrepancy in the SDK function targetClient.getOfferById(offersArray[i].id) call in that, it also needs type to construct the correct URL to fetch the offer.
Workaround is to maybe call the adobe.io rest API directly, since that works fine as mentioned above.
Permalink
shete
Aditi Shete added a comment - 6 days ago - edited
Withe the token and api key provided for tatadigital, with Accepts set to application/vnd.adobe.target.v2+json
I was able to run the adobe.io call successfully to get offers.
curl -X GET
'https://mc.adobe.io/tatadigital/target/offers?limit=10'
-H 'authorization: Bearer '
-H 'cache-control: no-cache'
*-H 'Accept: application/vnd.adobe.target.v2+json' *
-H 'x-api-key: '
Please investigate the the node.js side code which uses the Swagger client to make the above call (which seems to be succeeding with the apikey and token provided.)