How can I GET JSON and not XML in output of http Request

Hi there,

How can I GET JSON and not XML in output of http Request?
All I get is in XML format. I changed the format in url,body format but still getting XML format in output

Can anybody please help?

Thanks

In the AcceptFormat property you should set this to JSON

image

Also, ensure the output resource path ends in .json e.g. “c:\MyFiles\Output.json”

Tried. did not work. it again just gives me XML file

Is the resulting file saved as .json however?

Yes .
it is really strange.

If you put your resulting XML into this, Free Online XML to JSON Converter - FreeFormatter.com , will it provide the output you are intending?

Have you considered using code to convert from XML to JSON as a workaround?

  XmlDocument xmlDoc = new XmlDocument();
  xmlDoc.Load("InputXml.xml"); // Can use xmlDoc.LoadXml(YourString);
  string jsonText = JsonConvert.SerializeXmlNode(xmlDoc);
1 Like

image
Actually it seems my output file is a HTML file.

when I used converter I got below error msg.

Also, where can I code the code you sent for converting in uipath?
is it Invoke Code activity?

Hey @mahsa.mohk

it looks like your api is returning you html due to error.
Share response here what you are getting and regarding json opetion check the api output return type in API Doc First

Regards…!!
Aksh

1 Like

I want to get JSON output using API , httprequest. but I only get the output in XML format. and HTML.
I added output=json in my ENDPOINT. changed body format to “application/json”. changed acceptFormat to JSON, but still do not get JSON format in output.
can anybody know what is the issue?
is there any bug?
Thanks folks,

Yes, you will insert the code into the invoke code activity.

Thanks @aksh1yadav
your response gave me the idea of looking into my code again, I found the issue.
I can now get Json output.
Thanks all

Can you explain what the issue was in the end?

I have not passed a parameter and its value. so my output was in html, although the status code that I got was 200 which means Okay.( I still do not know why I got 200 code while my code was not correct!). anyhow, I passed the parameter and the response was okay then.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.