How to translate JSON Body into Text Body

Dear reader,

I am quite new to API and i am playing around a bit. I want to start API so I can use it in anther programs.

My first test were successful. I was able to run my API request and got the expected response back.
But the Body parameters are in JSON format. In Postman this is no issue but my other program only is able to use plain Text as a body.

the body in is very simple:
{
“username”: “{{username}}”,
“password”: “{{password}}”,
“domain”: “{{domain}}”
}

Can someone please lent me a helping hand and tell me how i should chenge this into plain text parameters?
Probably it will be very simple but i am unable to find the right sullution up to now.

Details (like screenshots):

That will be down to how your “other program” works.

I’m not 100% sure on what you are trying to achieve.

The Tests tab in Postman is basically JavaScript.

You will need to parse the response first and you can manipulate it however you want afterwards

jsonData = pm.response.json();

textObj = JSON.stringify(jsonData);

console.log(jsonData);
console.log(textObj);

You say to plain text, but what format?
Do you have an example of what the text should look like (based on that json example).

The above will return a JavaScript object enclosed in a string.

image

How is your other application going to consume this? (As you can’t write directly to the file system from within Postman). You say, so you can use it in other applications, but I’m unsure what you mean by that. Usually the other application will call the API directly.

Hi,

Thanks for your responce.
This post is to retrieve the access_code (bearer) of my horizon environmnet. In postman it works like a charm because I can select raw/JSON as a body input
But unfortunately the end applications does not allow JSON. It only allows raw/Text.

The thing I am looking for is on how I need to change the body if I select RAW/Text.

The JSON Input works like a charm:

{
“username”: “{{username}}”,
“password”: “{{password}}”,
“domain”: “{{domain}}”
}

But i am still puzzeling on how to make the body if I select Text in the pulldown:

I need to get the same access_code as with raw/JSON.

So can you please help me with the body I can copy past?

Cheers,
Edwin

You can’t change the body to text, if the API doesn’t support it.

REST API’s do not have to be JSON, but the majority are.

You need to read the API information to find out what it supports. (I doubt that it will be text though).

Sounds like you will need to have middle ware, something like an ESB (enterprise service bus) to perform the conversation for you if you really can’t get your application to send the request in the correct format. It unusual for an application to not support REST\JSON interfaces. It’s possible I guess that it only supports older SOAP interfaces which uses XML instead of JSON, and is where you set RAW\Text as the body.