# Error UNAUTHORIZED\_API\_CALL with Post Method JAVA

**URL:** <https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545>\
**Category:** 🙋🏽‍♀️🙋🏽‍♂️ Ask Questions\
**Tags:** request-signature, java\
**Created:** [April 4, 2023, 11:16am UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545 "2023-04-04T11:16:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcanare2](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/jcanare2/32/21592_2.png) [@jcanare2](https://community.rapyd.net/u/jcanare2)\
**Post date:** [April 4, 2023, 11:16am UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/1 "2023-04-04T11:16:47Z")

</div>

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/](https://jsonlint.com/))

 ![image](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/b/3/b38f124868c2d89f26c5c40abdae441f38645e23.png)

Is Sandbox enviroment

Request URL: [https://sandboxapi.rapyd.net/v1/addresses](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!

---

<div class="post-metadata">

**Author:** ![Community\_Team](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Community\_Team](https://community.rapyd.net/u/Community_Team)\
**Post date:** [April 4, 2023, 4:19pm UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/2 "2023-04-04T16:19:31Z")

</div>

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:

> **[Rapyd Documentation](https://docs.rapyd.net/build-with-rapyd/reference/address#create-address)**
>
> Liberate global commerce with all the tools you need for payments, payouts, and business everywhere.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jcanare2](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/jcanare2/32/21592_2.png) [@jcanare2](https://community.rapyd.net/u/jcanare2)\
**Post date:** [April 4, 2023, 4:23pm UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/3 "2023-04-04T16:23:14Z")

</div>

Thanks, but, is not POST ?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/rapyd/original/3X/0/c/0c34e38543631a80b5c055bce94371288f0f0459.png)

---

<div class="post-metadata">

**Author:** ![Community\_Team](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Community\_Team](https://community.rapyd.net/u/Community_Team)\
**Post date:** [April 4, 2023, 4:59pm UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/4 "2023-04-04T16:59:00Z")

</div>

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](https://sandboxapi.rapyd.net/v1/addresses) is as GET request. You have to send a POST request to create an address.

---

<div class="post-metadata">

**Author:** ![jcanare2](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/jcanare2/32/21592_2.png) [@jcanare2](https://community.rapyd.net/u/jcanare2)\
**Post date:** [April 6, 2023, 11:37am UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/5 "2023-04-06T11:37:14Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![drew.harris](https://sea2.discourse-cdn.com/flex016/user_avatar/community.rapyd.net/drew.harris/32/1259_2.png) [@drew.harris](https://community.rapyd.net/u/drew.harris)\
**Post date:** [April 6, 2023, 4:07pm UTC](https://community.rapyd.net/t/error-unauthorized-api-call-with-post-method-java/58545/6 "2023-04-06T16:07:50Z")

</div>


