Receive JSON format through REST api without using REST Client - magento

IN magento, as I am using REST api to get the product details with url like http://myserver.com/magento/api/rest/products? But this url returns only in XML format. But I need it in the JSON format.
Can anyone suggest me how to get it in JSON format without using REST client??

you need to set request header explicitly to application/json then the response is served in json.

Related

How to form http POST request to handle xml data file

My requirement is to accept xml data file that may be gziped in HTTPS POST request and request may be chunked.
Request body WILL have the type of application/.xml.
I am using Postman to make request and java spring to write the controller and rest of the api code.
My questions is how will my request will look like, either it will be form data with xml file in input or raw body with xml selected in postman.
I am finding it hard to make a curl for it.
Here is the example request requirement:

Download different content types with spring

I need to expose a POST endpoint where the user uploads an excel file and based on some validations, I either send back the file with some information added to it along with json response OR just send status code as 200 OK(no data).
I am trying to do this in spring boot. I tried following link:
https://javadigest.wordpress.com/2012/02/13/downloading-multiple-files-using-multipart-response/
This works but needs adding boundary manually. Is there any other way to do it so that I can send both the data ?
You should use #Produces as it is written here: https://docs.oracle.com/cd/E19776-01/820-4867/ghrpv/index.html
You can define the MIME-Type of your payload.

Rest End point not showing any json data when using POSTMAN application

I am trying to implement sample spring boot project and trying to retrieve result using POSTMAN application. But when using POSTMAN , I am not able to see that response for a GET request. But I can see by using browser properly. POSTMAN returning "Expected ':' instead of 't'" as result. But I can see result properly by using browser.
And my controller code is like the following,
#GetMapping("/check")
public List<Users> check() {
return (List<Users>) userObj.findAll();
}
Can anyone help me to find out why I am not able to see result using POSTMAN application please?
You are saying to postman (for that matter any client) that your api is producing json and instead you are returning just a string.
Check your header you will have a field called
Content-Type → application/json;charset=UTF-8
All you need to do is ensure you are sending valid json or remove that header entry so clients do not try to read it as json.
Or just to check you are getting right data by changing format from json to text in postman
You server application needs to understand the incoming request type. can you define the Content-Type=application/json and give a try.

Apache Nifi : How to pass post params and capture response from post API - traditional non rest, non json API

I'm trying to pull data from a post API that expects authentication and request parameters as part of the request body. I guess, what they do is access the data from the post variables.
What I have seen so far in documentation is how to send POST via JSON or headers. In my case, no headers just the post body parameters.
call to this api via curl --data option works just fine.
curl --data "username=xyz&password=xyz&function=xyz" http://example.com/api.php
How can I replicate above call in nifi?
I have tried multiple methods without success. Latest has been Generate flow file, update attributes (where i fill in the parameters), invoke http then putfile.
But I'm getting errors - the api is not abe to authenticate my request.
Thanks
If you need to send the following data in body, then put it into content of your flowfile.
username=xyz&password=xyz&function=xyz
The easiest way to put it into the Custom Text property of the GenerateFlowFile processor.
Usually for this kind of body you have to provide content type header:
content-type: application/x-www-form-urlencoded
If you don't need any additional headers then you don't have to define any additional attributes of the flow file.

Access data using ajax in json format from proxy url in shopify

I developed an app and defined a proxy url. I want to get the data from that url in json format in my shopify shop.But it is returning me nothing. If I read in html, It shows me data. Please tell where I am going wrong?

Resources