Problem with Rest API

Hi,
Actually im working on API’s ,in my process there where 5 Different API and able to hit four of them but the another one is not and giving 415 error status code. The same API is working fine in postman.Please help me out .

Thank you.

1 Like

Probably that is because the headers or the request type you are giving is incorrect.

Can you verify and try again

1 Like

checked all the headers and parameters are fine

1 Like

415 error is something that the media type you are giving is incorrect.
I got same issue earlier when i was giving the Content-Type header as application/xml instead of application/json.

Can you try again updating the package of UiPath.Web.Activities ?

1 Like

The problem has been resloved.

2 Likes

@siddharth18, Can you explain the changes you have made?

1 Like

The parameter which im passing are boolean type but in Http Request activity i n parameter data type is only accepting sting type,so i removed the parameter ,then it started working.

1 Like

I am having issues with the HTTP Request. In the wizard I retrieve the appropriate response in the preview but when running the script the response is not in json.

Capture3

Can somebody please help me figure out why this may be happening?

1 Like

@CiaraD

Can you confirm whether you are sending the header as " Accept" : “application/JSON”

And actually the above format is JSON but in the string text format, please try sending the header as above and check

1 Like

Unfortunately I have tried it that way too and it still doesn’t work. It appears as though it is not sending the headers at all when I capture it in Fiddler.

1 Like

@CiaraD I think because you are looking at the straight text instead of converting from JSON.

i.e. in C#

response = await client.PostAsync(
					"https://rpa.server.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
					new StringContent(myJson, Encoding.UTF8, "application/json"));
				toolStripTextBox1.Text = "Result: " + response.ReasonPhrase;

Where response = httpResponse
StringCOntent converts JSON encoded UTF-8 from application/json to string for the header use
then the Text Result is from the response httpHeader “ReasonPhrase” (the “text”)

1 Like

I am a little confused about your response. Can you be a little more specific about what I need to do to fix it?

1 Like

@CiaraD I’m not 100% sure, as I have only done this in C#, but, the idea is the response is not 100% readable as is. I think you need to deserialize it - then you can extract the string. Take a look at the “Deserialize JSON” activity. This UI Path activity takes a JSON string and turns it into a JsonObject.

Not sure how this is used though - I just don’t think you can use a straight JSON response - I think you need to work with it as a JSON object; but this is the limit of how I can help asn I’m nit sure of the precise details at this point.

I get an error when I try to deserialize the json array. Here is the response from Advanced Rest Client, which clearly shows me it is an array:

Here is the error I get in UiPath when I try to deserialize the array:

If I use the Deserialize JSON Activity I do not get an error but I am given JSON that has been stripped of it’s properties>

That is what made me come to the conclusion that the string was not being returned correctly from the http request.