Token Validation Failed (9201) for foreignexchangerates

TTBBANK
New Contributor

Token Validation Failed (9201) for foreignexchangerates

I got this error when trying to call https://api.visa.com/forexrates/v2/foreignexchangerates API and use x-pay-token for authentication

I have tried request to HelloWorld API and it worked.

Here is my request headers

POST /forexrates/v2/foreignexchangerates?apiKey=U0ZA115Y7BUYIQXJTGUF21PwqciBWLoKc-R5p-mloS0DCI1ro HTTP/1.1
x-pay-token: xv2:1685707360:534e3b01f238247677213a07266b8d58bdb431d44a0038460d38307de9588d7f
Content-Type: application/json
User-Agent: PostmanRuntime/7.32.2
Accept: */*
Postman-Token: 7cd60b08-d07d-4bd8-8bda-82fc5a190ff8
Host: api.visa.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 102

Here is my request body

{"rateProductCode":"A","destinationCurrencyCode":840,"destinationAmount":100,"sourceCurrencyCode":764}

Here is my response

{"responseStatus":{"status":401,"code":"9201","severity":"ERROR","message":"Token Validation Failed","info":""}}

 Here is my postman pre-request script

aaa.png

Here is my credential page

bbb.png

Please help. 

5 REPLIES 5
jenn_kh
Community Moderator

Re: Token Validation Failed (9201) for foreignexchangerates

Thank you for reaching out, @TTBBANK. An agent will get back to you as soon as possible. In the meantime, if any community member knows the solution, please reply to this thread!

I_Doroteo3
Visa Developer Support Specialist

Re: Token Validation Failed (9201) for foreignexchangerates

Hi @TTBBANK

 

The 401 Token Validation Failed error you're getting will be seen when the x-pay-token sent in the header is invalid. 

A couple of things I'd like you to note while generating the token: 

  1. For starters, please follow the getting started documentation to generate a valid token. https://developer.visa.com/pages/working-with-visa-apis#get-started-overview  
  2. APIkey in the url query param should be the same as the one used to generate xpayToken 
  3. “resourcePath” sent in the xpaytoken has to be as per the documentation (eg: v2/payments?apikey={apikey}). 
  4. Payload sent in the request payload should exactly match along with spaces to the “requestBody” value used in xpaytoken. 

 

Also, could you check to see if you're passing a correct value for URI. For example, make sure it’s defined correctly in the beginning of your code, and use the same value for the URI in the middle of your code. 

 

Thanks, 

Illana

alkesh
Regular Visitor

Re: Token Validation Failed (9201) for foreignexchangerates

Hi TTDBank,

Were you able to resolve the issue? I'm trying to resolve the same problem.

-AB
API_Managers
Visa Developer Support Specialist

Re: Token Validation Failed (9201) for foreignexchangerates

Hi @TTBBANK @alkesh,

 

Are you still experiencing an error? If not, please let us know so we can take you off our contact list. 




Thanks,

Tee



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

alkesh
Regular Visitor

Re: Token Validation Failed (9201) for foreignexchangerates

My issue has been resolved.