My Products
Help
JohanFriedrichsen
CONTRIBUTOR **

502 Bad gateway response but order is created anyway

by JohanFriedrichsen

Hi

I can see that there has been a few threads about the "502 Bad gateway" reponse before. Our problem isn't the response itself but the fact that the response doesn't reflect what is actually happening in the back end:

 

We try to send orders, get the 502 response but it seems like the order is created anyway. The problem here is that the response is treated as unsuccessful and therefor we try to send the order again which leads to duplicates in Visma.net. We need to be able to rely on the response and not have to double check everything.

 

Is this behaviour somthing that will change once we transition to the SalesOrder-API?

5 REPLIES 5
JohanFriedrichsen
CONTRIBUTOR **

by JohanFriedrichsen

I have done some more digging and here is the problem:

When we create an order we need some information about the created order to continue working with it. However, the order POST just responds with a 201 but no order payload so we need to manually fetch the new order to get the information that we need.

 

On this occation (5:th of january at 12:24) the POST was successful but a GET to the location header address from the POST resulted in a 502 Bad Gateway. That was seen as an incomplete POST and therefor the order was sent again resulting in a duplicate order. So technically it wasn't the API that created the duplicate but since the POST didn't respond with the created order (which is the most common way) it lead to the error.

 

From what I can see in the SalesOrder documentation the POST still doesn't contain a response payload so this logical problem can continue to come up in the future. How should this be handled in the best way?

Yıldırım
VISMA

You can read the newly created object ID upon successful POST request from the Response Header "Location"

More details can be found here.

JohanFriedrichsen
CONTRIBUTOR **

That is what we are trying to do but in the cases where the API-response is 502 we'll get a problem. Since customers want to to take advantage of the automations in Visma.net we need to know about the actual order created.

 

Would it be possible to include the created object in the response in the v3 version of the API? That would give us the information needed without an extra API-call.

Yıldırım
VISMA

Hello, you can create an "Idea"  about that. 

 

 

Yıldırım
VISMA

by Yıldırım

Hello, 

this is for sure not the way the API should behave. To be able to investigate in detail, we need you to elaborate your transaction. 
Could you share, 

 

1) Request URL 
2) Payload 
3) API ClientID & Company name & ID 

4) That specific call date / requestID

 

Also, has this happened only once or all of your requests are returning 502 but in fact the document has been created ?