Re: Generating HMAC in Sandbox for POST requests

Solved! Go to solution
michaelm
Regular Visitor

Generating HMAC in Sandbox for POST requests

Hi folks,

I am struggling to test the VISA Offers API (POST createwithevent operation). The issue is that I receive the error Status 401 (token validation failed).

 

Now, I HAVE successfully managed to get this working for GET requests where there are no payloads.

 

However, when I introduce a body into the request (and also the HMAC calculation), I get this error.

 

Can anyone advise how request bodies should be handled? Are there any examples?

 

8 REPLIES 8
cathy2981
Community Moderator

Re: Generating HMAC in Sandbox for POST requests

Thank you for reaching out, @michaelm ! An agent is looking for a solution for you and will get back with you shortly! If any community members know a solution, please feel free to respond in this thread. - Cathy

API_Products
Visa Developer Support Specialist

Re: Generating HMAC in Sandbox for POST requests

Hi @michaelm,

 

Visa Offers Platform is a restricted product. Were you granted content access to the Visa Offers Platform API?




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

michaelm
Regular Visitor

Re: Generating HMAC in Sandbox for POST requests

Hi Diana - I have access to the VISA OFFERS platform API yes. But it is not clear how the message body should be handled.

 

 

API_Products
Visa Developer Support Specialist

Re: Generating HMAC in Sandbox for POST requests

Hi @michaelm,

 

Please provide the following information about the error so that I can further investigate:

1. Endpoint
2. Request Header
3. Request Body
4. Response Header (include the x-correlation-id)
5. Response Body

Using SoapUI, you can find the x-correlation-id in the Raw Tab of the response header.




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

michaelm
Regular Visitor

Re: Generating HMAC in Sandbox for POST requests

https://sandbox.api.visa.com/vop/v1/offers/createwithevent
        _header: 'POST /vop/v1/offers/createwithevent?apikey=J28UXD9PLQTPR2EYIOWM21JI2EIALzKG5sO0RCrK9pw84KgZk HTTP/1.1\r\n' +
        'Accept: application/json\r\n' +
        'Content-Type: application/json\r\n' +
        'X-PAY-TOKEN: xv2:1645080572:ce7290f8fcfeefa1c51ef7c8b7f778855b8418cdf0c1911d9814575859364413\r\n' +
        'User-Agent: axios/0.25.0\r\n' +
        'Content-Length: 534\r\n' +
        'Host: sandbox.api.visa.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',

'{"endDate":"2018-03-10T18:00:00.000Z","templateName":"QATest81","name":"OfferName123","description":"OfferDescription","correlationId":"ce708e6a-fd5f-48cc-b9ff-ce518a6fda1a","externalOfferId":"1789910323","campaignName":"Rel8.1","events":[{"eventFields":[{"name":"TokenRequestorId","value":"40010030273"},{"name":"MerchantGroupName","value":"MG1CAID404"}]},{"eventFields":[{"name":"MerchantGroupName","value":"MG1CAID404"},{"name":"ClearedUSDAmount","value":"19.00"}]}],"startDate":"2017-03-10T18:00:00.000Z","communityCode":"PB29CL"}'

response: {
    status: 401,
    statusText: '',
    headers: {
      server: 'nginx',
      date: 'Thu, 17 Feb 2022 06:49:33 GMT',
      'content-type': 'application/json',
      'content-length': '112',
      connection: 'close',
      'x-served-by': '-879c64v5',
      'x-correlation-id': '1645080573_567_126453540_-879c64v5_VDP_WS',
      'x-vdp-normalized-url': '/vop/v1/offers/createwithevent',
      'x-app-status': '401',
      'x-vdp-authn-api-visa-id': 'VOP.105',
      'x-error-origin': '9100',
      'x-frame-options': 'SAMEORIGIN',
      'x-xss-protection': '1; mode=block',
      'x-content-type-options': 'nosniff',
      'strict-transport-security': 'max-age=31536000;includeSubdomains',
      'cache-control': 'no-cache, no-store, must-revalidate',
      pragma: 'no-cache',
      expires: '-1'
    },

{
  responseStatus: {
    status: 401,
    code: '9159',
    severity: 'ERROR',
    message: 'Token Validation Failed',
    info: ''
  }
}
API_Products
Visa Developer Support Specialist

Re: Generating HMAC in Sandbox for POST requests

Hi @michaelm,

 

I ran a sandbox test today using VDP Playground and I received a successful request/response payload with 200 OK. Please try your test again and share your result with us.

 

Below is my sample request/response payload. Also, please make sure to use the Test Data of your project app. The test data for your Visa Developer application is available in the Dashboard under test data in the left navigation, this will ensure that you are using valid data that has been provisioned for specific scenarios.

 

20190905 Test Data.png

 

End Point https://sandbox.api.visa.com/vop/v1/offers/createwithevent
Method POST
Request
{
"endDate": "2018-03-10T18:00:00.000Z",
"templateName": "TESVDP",
"name": "DemoOffer0015502",
"description": "Offer Description",
"correlationId": "ce708e6a-fd5f-48cc-b9ff-ce518a6fda1a",
"externalOfferId": "1789910323",
"campaignName": "Miscl",
"events": [
{"eventFields": [
{
"name": "TokenRequestorId",
"value": "40010030273"
},
{
"name": "TransactionUSDAmount",
"value": "19.00"
}
]},
{"eventFields": [
{
"name": "MerchantGroupName",
"value": "MG1CAID404"
},
{
"name": "ClearedUSDAmount",
"value": "19.00"
}
]}
],
"startDate": "2017-03-28T22:00:00.000Z",
"communityCode": "PB29CL"
}
Response
{
"responseDateTime": "2022-03-02T01:07:56Z",
"offerId": "43360260",
"correlationId": "ce708e6a-fd5f-48cc-b9ff-ce518a6fda1a",
"externalOfferId": "1789910323",
"responseStatus": {
"code": "SUCCESS",
"message": "Request proceed successfully without error."
},
"communityCode": "PB29CL"
}
Response Header
Status Code: 200 OK
Server : nginx
Date : Wed, 02 Mar 2022 01:07:56 GMT
Content-Type : application/json
Content-Length : 267
Connection : keep-alive
X-SERVED-BY : -65f5b458b2
X-CORRELATION-ID : 1646183276_776_1313810665_-65f5b458b2_VDP_WS
X-APP-STATUS : 200
Cache-Control : no-cache, no-store, must-revalidate
Pragma : no-cache
Expires : 0 ,-1
X-Frame-Options : SAMEORIGIN
X-XSS-Protection : 0
X-Content-Type-Options : nosniff
Strict-Transport-Security : max-age=31536000;includeSubdomains
X-XSS-Protection : 1; mode=block
X-Content-Type-Options : nosniff
Strict-Transport-Security : max-age=31536000;includeSubdomains;always

 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

API_Products
Visa Developer Support Specialist

Re: Generating HMAC in Sandbox for POST requests

Hi @michaelm,

 

Is the issue fixed? 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

API_Products
Visa Developer Support Specialist

Re: Generating HMAC in Sandbox for POST requests

Hi @michaelm,

 

I haven't received an update from you, hence, I'll take you off my contact list.  Please do not hesitate to reach out to us if you have any questions or need further assistance. 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.