cancel
Showing results for 
Search instead for 
Did you mean: 

Web API service response

AkshayaR
Level 3
Hi Team,

We have been trying to send a POST request to REST API service. The response is received as expected while trying to send the request in postman/ARC as well as through Utility - HTTP VBO. But while trying to configure the same through Web Service API under System tab, the response status code is updated as 200 but the response content is received as a series of non printable ascii characters.

We need your inputs on what we are missing here.

Thanks,
Akshaya

------------------------------
Akshaya R
------------------------------
14 REPLIES 14

ewilson
Staff
Staff
Hi @Akshaya R,

What is the REST API returning to you? Is it a file of some sort? If it's binary content (ex. a PDF, zip file, etc) the Web API service feature should be avoided for that action. The issue here is the feature only supports returning Text-based data. There are a few threads on the Community about this. We've opened an enhancement request with product engineering to get this behavior changed, but not sure when that will happen.

In the meantime, what I've done from time-to-time, is implement any API endpoints that expect some sort of binary content in the return using the HTTP VBO. All others can be implemented within Web API. Alternatively, and really a cleaner approach, is to just implement that entire REST API connector using the HTTP VBO. That way you have a single asset as opposed to two.​

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi Eric,

The output of API response is supposed to be JSON and this is what postman and Advanced rest client also have been returning as expected.
Web API service alone sends a response with random characters even though status code is 200.

Please refer the attached image for the response detail.

Thanks,
Akshaya

------------------------------
Akshaya R
------------------------------

@Akshaya R,

I see some references to ServiceNow in your flow. Is this call to Get Bearer Token a call to ServiceNow? It will help my review if I know the specific API and endpoint, so I can review the documentation.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Eric, 

Please ignore all stages other than the one linked immediately after start stage. That is the one that we tried using web API service. 

We are not using any bearer token. That stage was copy pasted from another process and hence the name wasn't changed. 

Thanks,
Akshaya

------------------------------
Akshaya R
------------------------------

@Akshaya R,

Ok, but to be clear this is a call to one of ServiceNow​'s REST APIs? 

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Yes right Eric!

------------------------------
Akshaya R
------------------------------

@Akshaya R,

Ok. Hopefully my last question on this. Is this the Table API, Case API,....? ServiceNow has several REST APIs, so I need to narrow it down. I think, based on what I can see from the stage name that this is the Table API, and you're trying to create a task in some table (ex. incident_task). Can you post a screen shot of the actual URL you're posting this request to?

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi Eric,

We are trying to create a service catalog task here by sending request to REST API SR (service request) table.

About the URL, I am afraid I wouldn't be able to share the details here since its confidential.

Thanks,
Akshaya

------------------------------
Akshaya R
------------------------------

@Akshaya R,

Understood. If this is the Table API that you're using the path portion of the URL will look something like this:

https://[YOUR TENANT URL]/api/now/table/[TableName]

It could look like this if you're calling a specific version of the API:

https://[YOUR TENANT URL]/api/now/[API_Version]/table/[TableName]

​This API supports a few query parameters too. The one I see that looks like it will impact the return data is sysparm_display_value. From the ServiceNow API documentation:
Determines the type of data returned, either the actual values from the database or the display values of the fields. Display values are manipulated based on the actual value in the database and user or system settings and preferences.

If returning display values, the value that is returned is dependent on the field type.
- Choice fields: The database value may be a number, but the display value will be more descriptive.
- Date fields: The database value is in UTC format, while the display value is based on the user's time zone.
- Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.
Reference fields: The database value is sys_id, but the display value is a display field of the referenced record.
- Data type: String

Valid values:

- true: Returns the display values for all fields.
- false: Returns the actual values from the database.
- all: Returns both actual and display values.

Default: false​


If you notice, the default setting of this parameter is false which means it's returning actual database field values. If a field contains binary/hashed/encrypted data, that's what's being returned. You might try setting this field specifically to true and see if that addresses the issue. Otherwise, you can use the sysparm_fields query parameter to specify the list of fields to return (accepts a comma delimited string of field names to return). Start with just one or two fields and see how that works. Then you can add on to it from there.

You said this works fine in Postman. You can also take a look at the specific Postman request and verify what, if any, query params are specified there.

Cheers,



------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------