Solved

Is there an example how to build the HTTP request for an open API request?

  • 2 October 2023
  • 2 replies
  • 80 views

Userlevel 4
Badge +14

I want to use an open API request as described in Case: A message protocol-independent web service (part 1 of 2) by @Anne Buit, to exchange data in JSON format between two different Thinkwise applications. 

When I execute the request in Insomnia, it works fine (http response status 200 with request body). When I execute the request with the HTTP request in a process flow, I get a status code -1 with HTTP response status 0. 

When I look in the database event log of Indicium, I can see the request is processed, but without succes. There is a response header, but I can’t find a reason.   

Is there an example how to build the HTTP request for an open API request? What headers should be provided etc?    

icon

Best answer by Vincent Doppenberg 10 October 2023, 14:23

View original

This topic has been closed for comments

2 replies

Userlevel 6
Badge +4

Hello @Andre te Raa,

A few things come to mind, but I’m going to need some more information in order to help you.

First of all, it’s important to know where exactly the issue occurs:

  • Does the request from Indicium1 even reach Indicium2? The status code being 0 indicates that this might not be the case. The network infrastructure (e.g. a firewall or some kind of routing rule) might cause Indicium1 to be unable to reach Indicium2. I would expect an error message in the error log of Indicium1 if this is the case. Can you check the error log and share any errors pertaining to this request?
  • Is the request from Indicium1 rejected by Indicium2 due to a malformed URL or header, missing header or missing authentication? In most of these causes I would expect an error in the error log of Indicium2. I don’t think that this scenario is very likely given that the status code of the request is 0, but it’s worth checking the error log of Indicium2 anyway.
  • Is the request from Indicium1 accepted by Indicium2, but is the response simply not what you expected? In this case there must be some kind of subtle difference between the requests that causes your process procedure to not handle the request correctly. If this is the case, you should at least be able to determine that the request actually reaches your process procedure by logging incoming requests to a table. From there it should be easy to determine what the difference is between in the incoming parameter values.

For the last two cases it should be noted that Insomnia adds some default headers to requests (e.g. User-Agent, Accept and Content-Length) even when you don’t specify them yourself. You can check the yellow text in the Timeline tab of Insomnia to see which headers Insomnia sent. In particular the Accept and Content-Length could make a difference here. For example, a POST request requires a Content-Length header, even when no content is posted. Until recently, Indicium would not add Content-Length: 0 automatically, but we have added this a few months ago. So ensuring that your Indiciums are up to date could also help fix this issue.

So in short, if none of the above has fixed your issue, then I would like to receive the following information in order to help you further:

  • The error logs of both Indiciums
  • The full HTTP response of the HTTP connector, including the status code, response headers and response content. You should be able to log these somewhere using a process procedure on the HTTP connector.

I hope this helps.

Userlevel 4
Badge +14

Hi Vincent, 

The database event log of Indicium showed already that the request was processed. I added logging to the begining of the procedure that handles the request and my request is logged in the table. 

Based on your response I also added logging to the end of the procedure. That is logged also.

I noticed that the process variable response_status_code (property response code) was empty and stays empty. So I changed the procedure again and filled the response_status_code with 200 myself. That seems to be the solution. Now the process monitor shows a status code 0 with a response JSON. 

Thanks for your help!