Consuming REST Api: Problem with URL

Hi,

I am consuming rest API and it supports sorting. So when I call the API from test window and try to sort with "-" as an input parameter, I am getting the results that I am expecting.But when I try to sort it from the UI, I am getting 500. I already enabled the full logging in service center.

From logs I noticed that it's not sending the full  URL (http://example/forms?sort=-&pageNumber=1 HTTP/1.1 ). Deleted everything after "-" in sort. 

Thank you.

Error 500 is the HTTP error code for a server error in the called service so the error is coming from the actual REST service you are calling. Try switching on Full logging in your rest service inside service center for that espace (under the Integrations option), that way you will be able to see exactly what is being sent to the other end in the Integrations log from Service center as well as the actual error message being returned by the REST service.. 


Hi Nannu,

can you explain what the yellow part is doing there, it doesn't look like the right thing to put there.

I would imagine more like ....forms?sort={}sortFirstName}&pageNumber={PageNumber}&...

Dorine

Jeanene Williams wrote:

Error 500 is the HTTP error code for a server error in the called service so the error is coming from the actual REST service you are calling. Try switching on Full logging in your rest service inside service center for that espace (under the Integrations option), that way you will be able to see exactly what is being sent to the other end in the Integrations log from Service center as well as the actual error message being returned by the REST service.. 


 

 Hi, as I mentioned in my post above I already enabled the full logging and from logs I have noticed that it's not sending the complete url. (http://example/forms?sort=-&pageNumber=1 HTTP/1.1 ). Deleted everything after "-" in sort.  

How if the input character is not "-", is it the same result? or u can try to put the sort input parameter as the trailing (last parameter)?

regards


Dorine Boudry wrote:

Hi Nannu,

can you explain what the yellow part is doing there, it doesn't look like the right thing to put there.

I would imagine more like ....forms?sort={}sortFirstName}&pageNumber={PageNumber}&...

Dorine

 

 Hi, {sortFirstName} is to hold the  "" or "-" value and after that (yellow part) I am sorting on first name, which is inside patient structure. It's working on the Postman.


Another try, from the UI, just hardcoded the "-" and other parameters, is it still wrong?

Solution

Ok done some tests for you. Outsystems does not seem to support using a variable plus fixed text in the URL parameter if it is after the =. All of the following 3 just result in only the variable being passed and not the text


{Variable}test&

test{Variable}&

test{Variable}test&

all return just the variable


What you need to do is pass the actual full text you need instead of just the -

eg assign "-patient.name.first" to a string and pass the entire thing so your URL will look like

sort={sortstring}&pageNumber=

If you need to have the - as optional just append them in code when passing the parameter to the REST call


Or put the patient.name.first into a variable if you want that configurable.

Solution

Just to confirm, after doing as suggested above the parameter comes through in full with the minus

Jeanene Williams wrote:

Ok done some tests for you. Outsystems does not seem to support using a variable plus fixed text in the URL parameter if it is after the =. All of the following 3 just result in only the variable being passed and not the text


{Variable}test&

test{Variable}&

test{Variable}test&

all return just the variable


What you need to do is pass the actual full text you need instead of just the -

eg assign "-patient.name.first" to a string and pass the entire thing so your URL will look like

sort={sortstring}&pageNumber=

If you need to have the - as optional just append them in code when passing the parameter to the REST call


Or put the patient.name.first into a variable if you want that configurable.

 Thank you so much for your time.You are absolutely right. That's what I have noticed and I took the same approach and it worked for me. I put everything in the single variable.