Converting SOAP Response XML to JSON using XSJS - json

I'm having problems to convert an XML response file to JSON using XSJS, Any help will be appreciated. Thanks!

It is actually pretty simple. While sending the request using XSJS to the server...your URL path should contain the format specifier.
http://myhost:8000/exampleapp/resource.xsjs/some/more/options?$format=JSON
or if you do not want to append to the URL then include the following line your request header
accept: application/json

Related

How to POST with JSON Data using EasyCron

I am trying to post json (as opposed to form data) using easycron. I see there is a Data input, but in the examples it appears to be for querystring or form data foo=bar&baz=bop?
I have been trying to do it with headers to no avail:
Content-Type: application/json
Data: '{"my":"json"}'
I feel like I'm very close as my endpoint is just complaining about the json payload being empty. What am I missing?
Turns out you can just put json in the data input. Though you still need to set the response header content-type.
response header:
Content-Type: application/json
data:
{"my":"json"}

PhpStorm/WebStorm REST client: easy way to send JSON?

In 2017 versions of PhpStorm / WebStorm there is a REST client we can use to send requests and analyze responses.
By default, when I send a POST and use the easy form in the UI to create request params, the parameters are formatted as x-www-form-urlencoded
instrument=JPY&id=6
I want to send data as JSON. So I thought if I add the content-type: application/json header, the IDE would format the request params accordingly, but it doesn't.
Currently the only way I see to send stuff in JSON format is to craft the JSON myself and put it in the Request Body as Text section of the IDE
Am I missing an easy way to send JSON?
You're not missing it, it's not there yet. Please vote: https://youtrack.jetbrains.com/issue/WEB-17342

Is it possible to attach file in POST Json?

I have a heap of data in format JSON(Serialized object).
I send this data to server by POST method with header: Content-Type: application/json.
Is it possible to attach file to body request and send at once. Or JSON data sugggests sending only text data?
In this context, the content-type header aims to describe the type of data in the request body.
If you use application/json the server will expect a JSON body.
If your goal is to send a single request with a JSON object and a file, you can either encode the file in the JSON structure (Probably base64. See: Binary Data in JSON String. Something better than Base64)
{
...
file: "encoded_content",
...
}
Or you can use the content type multipart/form-data.
A multipart is a part containing other part.
The first subpart may be the JSON strucuture. The second one may be the file
Try to send the file inside the json object as a base64 string:
{
"file":"dGhpcyBpcyBhIGZpbGUgc2FtcGxl..."
}
Later you can open the file with something like:
document.location = 'data:application/pdf;base64,' + file

Pentaho HTTP Post multipart/form-data

I am trying to use HTTP Post to post the data by passing following Header and Body part,
Body:
One image URL having file path. Type as 'File'
Metadata in JSON format. Type as 'Text'
Headers:
Content-type = multipart/form-data
Authorization = Bearer 5412
Here is the screenshot of complete request,
This is how I have setup the HTTP Post task in Pentaho,
I found related post here using REST Client but this also didn't help: Pentaho HTTP Post using JSON
Really appreciate your help.
I think the problem is that "Post a file" doesn't mean include a file in the request, but rather to get the entire request from that file.
I don't know the specifics of how the data should look in the Post request, but the rough approach should be:
Pass the filename field to a Calculator step with the operation "Load file content to binary" to get a binary type field (ex: myimage)
Base64 (or other) encode the data with a Javascript step like this:
var encString = new Packages.java.lang.String( Packages.org.apache.commons.codec.binary.Base64.encodeBase64( myimage ) );
Wrap it in some content-type string indicating the encoding
Include the field in your request.
There is a patch on https://jira.pentaho.com/browse/PDI-14743 to enable proper binary transfer instead of String when using Rest Client.

JSON return format cordys BOP

I'm using Cordys BOP and I have a REST web service that returns JSON format. I have a test service that I use, that returns XML and this works fine so I know that my HTTP connector works right. When I try to test my JSON service using the Test Web Service Operation UI, I get an error that says Invalid XML response.
How do I tell Cordys to expect a JSON response instead of an XML?
Is there a way to somehow wrap a JSON in XML through Cordys?
You probably need to change the header:
Content-type: application/json