Rest API Get Parameter not working

Rest API Get Parameter not working

  


Hi,

I'm evaluating Outsystems (Service Studio 9.1) for my company, and testing integration with ServiceNow.  I've created the API Get request shown above with the TaskId parameter, and successfully tested with appropriate results as above.  

However, when I call this module from a preparation step for a screen, passing tthe same parameter value (TASK0020033) through a local variable, I get a completely different record returned with a different value from the passed TaskId.  In fact, the record that I'm receiving matches the very first record in a response for a query that specifies no TaskId parameter at all.

I'm not able to see the actual parameter value that the api module is using, as debug says it's not available in the context.  I'm stumped on how to further debug or resolve this issue.

Thanks!







Hi Bill, 

First of all, thank you for trying OutSystems, I hope that you will not be disappointed  ;)

Related with your issue, as far as I can tell for what you described, the TaskId isn't been passed in the request.

For debugging purposes, you can activate the trace for that REST API in Service Center in order to have the full payload in ServiceCenter monitoring pages.

To activate this, go to: ServiceCenter > Factory > eSpaces > "select your espace" > Integrations > "Select your REST API". Then, in logging level, set it to "Full".

Then, in Monitoring, you can see the payloads of requests sent for REST APIs in ServiceCenter > Monitoring > Integrations

With this, you can see what is being passed in your requests.


There are some reasons that why you parameter is not being passed and the most common is: you have a default value set as the same value you are passing and the property "Send Default Value" is set as "No".


Let me know if it helped.

I'll wait for your feedback.

Thanks.


[edit]

Other thing you can try is to remove the "%3D" from your request and replace it with ":". we already encode the request for you.

Hi Nuno,

Thanks for your quick response.  Sorry I'm slow to get back to you on this, but unfortunately I've been unable to redeploy the app this morning:
Connection time out

Connection timed out while contacting 'wstanislaw.outsystemscloud.com'.

Check your network connection and if the problem persists increase the 'Short operations Timeout' value in Preferences.

That timeout value is set at 60 seconds.

This has not happened before today, and I've been trying to redeploy off and on for the past 3 hours.  I've also tried to publish other apps, but had the same result.  I've asked my network/security team to look into this in case anything has changed overnight on our end.

I did flip the integration monitor logging to "Full", but there's been no change in the logged events I saw using the previously deployed version.  I'm guessing I'll need to recompile/deploy with those settings in effect.

I'll keep you posted on progress here.

Thanks again.


Hi Bill,

The setting become active right away, but the request log and request detail will take a little long to arrive because you are in a Personal Environment.

I must say that you need to perform the request again to have new logs on this.

Let me know if I can help you.

Thanks

Solution

Hi Bill,


Just noticed that in your url the parameter is in the format   sysparam_query=number%3D{TaskId}

There is currently a known issue with urls like those, where after the = there is still partial text.around the parameter Can you rewrite it as  sysparam_query={Query} and then pass as input value "number=" + TaskId   ?


Regards,
João Rosado

Solution

Yes.  That was the issue.  I was just about to reply with more symptoms, but your suggested resolved the issue. Thanks...


The parm value is being passed.

Here's what trace shows as being passed in a Test from the Get module, which yields a successful result:

GET https://dev19209.service-now.com/api/now/table/task?sysparm_query=number%3dTASK0020033&sysparm_display_value=True&sysparm_exclude_reference_link=True&sysparm_suppress_pagination_header=True&sysparm_fields=description%2csys_class_name%2cclosed_at%2cclosed_by%2cstate%2csys_created_on%2copened_at%2cnumber%2cassignment_group&sysparm_limit=1 HTTP/1.1


Here's what happens when the application calls the api with the taskid parameter, with wrong record returned:

GET https://dev19209.service-now.com/api/now/table/task?sysparm_query=TASK0020033&sysparm_display_value=True&sysparm_exclude_reference_link=True&sysparm_suppress_pagination_header=True&sysparm_fields=description%2csys_class_name%2cclosed_at%2cclosed_by%2cstate%2csys_created_on%2copened_at%2cnumber%2cassignment_group&sysparm_limit=1 HTTP/1.1

The sysparm_query is being invalidated when the app makes the call - note that number%3D is removed.

Same result when I flip the %3D to a colon in the api method:

GET https://dev19209.service-now.com/api/now/table/task?sysparm_query=TASK0020033&sysparm_display_value=True&sysparm_exclude_reference_link=True&sysparm_suppress_pagination_header=True&sysparm_fields=description%2csys_class_name%2cclosed_at%2cclosed_by%2cstate%2csys_created_on%2copened_at%2cnumber%2cassignment_group&sysparm_limit=1 HTTP/1.1

So, why would the API test function act differently in this regard than the api generated in the app?


Well, it was supposed to be the same. The API test feature has the correct behavior.

But the code in runtime is a bit more complicated to allow the parameters to be customized inside the OnBeforeRequest callback, and the text around the { } is being lost in the process.


At the moment I can only recommend using that workaround and avoiding the issue (until it is fixed, but I don't have a timeframe for that)


Regards,
João Rosado

No problem - glad you were able to point this out, and hopefully others will benefit from this conversation.


Thanks again!!!