Error UNAUTHORIZED_API_CALL with Post Method JAVA

Good morning guys, greetings!

I’m having problems when making a request of type POST in Java.

This is the way I analyze the body:

Gson gson = new Gson();
String bodyString = gson.toJson(address);

String to be encrypted for signature:

post/v1/addressesdvrbynoeyc1680606300rak_886832C4E8581C1604C2rsk_88f33b33fa5f45fb74c2902a180fe87423834672f1974c6d176bc706a392d79865e92f5a798c6b3a{“canton”:“”,“city”:“Anytown”,“country”:“US”,“district”:“”,“line_1”:“123 State Street”,“line_2”:“Apt. 34”,“line_3”:“”,“metadata”:{“merchant_defined”:true},“name”:“John Doe”,“phone_number”:“12125559999”,“state”:“NY”,“zip”:“12345”}

The JSON is valid (https://jsonlint.com/)

Is Sandbox enviroment

Request URL: https://sandboxapi.rapyd.net/v1/addresses
Method: POST

Error:

401 Unauthorized: [{“status”:{“error_code”:“UNAUTHORIZED_API_CALL”,“status”:“ERROR”,“message”:“”,“response_code”:“UNAUTHORIZED_API_CALL”,“operation_id”:“72551f5d-7b3d-4781-a5c5-a05e6613438d”}}]

Any idea what I may be doing wrong?
I hope you can help me guys, thanks!

Hi @jcanare2

Regarding this specific error, it seems that you are sending a GET request, instead of a POST. That explains the UNAUTHORIZED_API_CALL error.

Your client is hitting:

request: GET/v1/addresses

You have to send a POST request as documented here:

Hope this helps!

Thanks, but, is not POST ?

Hi @jcanare2

Yes, that is the string to calculate the signature. Thats seems correct.

But the actual http request that you are sending to https://sandboxapi.rapyd.net/v1/addresses is as GET request. You have to send a POST request to create an address.

1 Like

Yes, indeed, it was the call

I leave it here in case it helps someone:

For Java Request Post Method:

HttpEntity<?> entity = new HttpEntity(bodyString, headers);
restTemplate.postForObject(urlPathLarge, entity, Response.class);

Thank you so much!