Consuming REST API Only Return HTTP Status

Hello,

I want to consume a REST API method with 3 headers input parameter.

Tested in Postman, works good with the JSON returned.

Meanwhile when i run the test on OutSystems REST API Consume it only return "HTTP/1.1 200 OK" without anything else. Did i miss some step?

I tried to manually copied the JSON from Postman to the OutSystems REST API Body, it successfully generated the Entity but when i try to display the data using feedback message or through a screen nothing appears.

Thanks in advance

Have you debugged and stepped through the code to see if the response contains any data?

Hanno wrote:

Have you debugged and stepped through the code to see if the response contains any data?

Hi Hanno,


Yes I did try debugging and step through the code, it's all empty.

Like i mentioned above.

Meanwhile when i run the test on OutSystems REST API Consume it only return "HTTP/1.1 200 OK" without anything else.

But in Postman it return the JSON body with all the data.

Can you perhaps share the .oml? If not here send me a private message...

Hanno wrote:

Can you perhaps share the .oml? If not here send me a private message...

Well, the web application i made is the same as the one from OutSystems course.

My question is why when i run the test on Consume REST API it only return "HTTP/1.1 200 OK"  while on Postman it gave me the JSON Response with full information (Name, phone, birthdate, etc).


Kevin Wie wrote:

Well, the web application i made is the same as the one from OutSystems course.

Well, there are a number of courses/sample apps. Can you perhaps share the link for the one in question?

My question is why when i run the test on Consume REST API it only return "HTTP/1.1 200 OK"  while on Postman it gave me the JSON Response with full information (Name, phone, birthdate, etc).

There could be a few reasons why this is happening. One that comes to mind is the naming of the JSON structure.


Hanno wrote:

Kevin Wie wrote:

Well, the web application i made is the same as the one from OutSystems course.

Well, there are a number of courses/sample apps. Can you perhaps share the link for the one in question?

My question is why when i run the test on Consume REST API it only return "HTTP/1.1 200 OK"  while on Postman it gave me the JSON Response with full information (Name, phone, birthdate, etc).

There could be a few reasons why this is happening. One that comes to mind is the naming of the JSON structure.


This one

https://www.outsystems.com/learn/lesson/1850/retrieving-data-from-a-rest-api-get/


Thanks


Kevin, can you perhaps indicate what parameters you are passing? Consuming the API as specified in the course material works fine?

Hanno wrote:

Kevin, can you perhaps indicate what parameters you are passing? Consuming the API as specified in the course material works fine?

In the Headers/Auth tab, I have 3 Request Headers parameters, which is Account, Username and Password.

And yes, consuming the API as specified in the course material works fine.

Kevin is the API you are consuming a POST or GET?

Are you passing the username and password in the fields provided, or are you setting custom headers?

Are you setting a custom header for the Account parameter?

Generally, with a GET, the parameters are passed in the URL, and with a POST, the account would typically be in the body. I am guessing that the method of the API is GET?

Any chance you can share the URL for the API?

Hi Kevin,

Usually when something like this happens, it's missing filter or pagination parameters. Also, do you expect a list or a single record? If the former, do you see the empty list being returned? ("[]"). It would help if you could show the same pop-up Hanno did, showing the empty resonse.

Hello Hanno,

Kevin's colleague's here. We don't really know if we can share the API or not. But I can send you a censored screenshot regarding this issue.

We are currently trying to consume a GET method from REST API.

First, this is the screenshot when we tried to hit the API with Postman

as you can see, the API that we hit with 3 headers above, it returns some data for us to fetch. But when we tried to hit it from Outsystems with the same URL, headers, and header's value, here's what happened


as you can see the output of this API between postman and Outsystems are different. What do you think we did wrong in this case?


We are really sorry we cannot give you the API that we access in this case. But I hope the screenshots help. Thankyou.


Regards,

Hentry

Hi Hentry,

It certainly looks like you didn't do anything wrong. Since the URL of the service you're calling ends with "outsystems", is there any way you can contact the team or company that created the API? They may be able to tell you what happens (I think it's pretty weird they send a 200 without any body).

Hi Killian,

We've contacted the team that create this API and they said there was nothing wrong with this API since they had already tried it in Postman and it worked perfectly.(as you can see the screenshot from postman that I send in the last post). Is there any chance that this error/bug caused by Outsystems itself?

Thanks


Regards,

Hentry

As Killian said, it looks okay.

I have found in the past though that the platform server sometimes appends ";utf-8" to some of the headers. Perhaps try and modify the headers in the OnBeforeRequest callback of the API and remove this value, or at least debug it and see what gets sent in the headers list.

Once you have what OutSystems sends in the headers, you could try and recreate in Postman..

Hi Dragon,

It's more that I would like the team to check their loggings (if they have any) to see whether they can trace your call and see what they returned. But I feel that they're not willing to do that if they have given such an answer...

What I would do is to actually add the Method including the right parameters etc. to the Module, then create a small testing app that calls it. Before you actually run it, increase the logging level of the specific REST service and afterwards check what gets actually sent and what is actually returned. That way also help you with the other team.

Also try adding the OnAfterResponse event to your API and call it with code, you can then set a breakpoints in there and see more details about what is being returned in the response property such as headers, the raw body etc. I find this a useful way of debugging API calls



Hello all,


I've tried of what you guys suggested before. I've tried to duplicate the header request from Postman to Outsystems. Still it returned only status code 200 when I tested it.

I was getting desperate and tried to call the API from javascript. I called it in web and mobile. And it returns an error in the console. This is the error message:


I was thinking if it was possible that this is the reason why in Outsystems IDE did not return anything but the status. Thanks.



Regards,

Hentry

Solution

Adding extra header "Accept-Encoding" with the value of " * " fix the problem as suggested by the support.

Thanks guys, it's finally solved.

Solution

Thanks for the feedback Kevin!