Data-form to Raw Json Format - json

I'm trying to covert an data-form entry into a Raw Json Format in a POST API call on Postman and it's not working well.
The API Instruction for data-form input:
And it's works well when I use that data-form configuration for my API:
But the problem is that I must convert that data-form arguments input into a Raw Json format and it's not working.
The way that I'm trying to use as Raw Json format (Content-Type already as application/json) is:
{
"arguments": {
"Hi_eid": "*******-****-****-****-e2e1bf4c52e9"
}
}
The wierd thing is that the status says thats working "200" but the response says that the data was invalid as Invalid collection string. And I don't know what I'm doing wrong.
May someone help me with that issue?

Related

Unable to Extract value from JSON response which has the data in "\"

Please help me to get out the problem which I am facing. I have a JSON response like this:
"{"Version":10,"Collections":[{"Id":"*******","Name":"","Description":null,"IsValid":false,"ABC":"\\XYZ\\collection\\","C
and want to fetch the values of collections which has n number of Id's but JSON extractor is not working here.
Don't post text as image otherwise even those who are willing to help won't re-type your code or use OCR software in order to reproduce your issue
What you're showing to us is not a valid JSON, you can check it yourself using an offline or online JSON Lint Tool hence you won't be able to use JSON Extractor for this.
If you get escaped JSON as a part of some JSON attribute, like this one:
{
"some-attribute": "{\"foo\":\"bar\"}"
}
You won't be get this bar value directly so you will need to do this in 2 steps:
Use 1st JSON Extractor to get the value of some-attribute
Use 2nd JSON Extractor to get the value of foo attribute
Demo:
More information: API Testing With JMeter and the JSON Extractor

Jmeter JSON Format Post Processor breaks Token retrieval

I am working with Jmeter and i want to format the JSON results. So i installed JSON Format Post Processor and added it to the root of the project.
It works correctly, it formats the JSon response for easy readability. However there is also a request with requires Token authentication. It does not work with the JSON Format Post Processor.
Example:
Correct coin retrieval without JSON Format Post Processor:
{"access_token":"Secret","expires_in":3600,"token_type":"Bearer"}
And with:
{
"access_token": "Secret",
"expires_in": 3600,
"token_type": "Bearer"
}
I use a regulair extractor to extract the token: access_token":"([a-zA-Z0-9.\-\_]*)
This seems to break in combination with the formatter. No valid token access is denied in all requests
Is there an easy way around this? It seems i can either use Jmeter JSON Format Post Processor for my complete project, or not at all.
Anyone know how i deal with this?
If it is possible, apply JSON Format Post Processor after regex extractor. This could help.
For easier access to data in JSON format you can use JSON Path Extractor or SmartMeter's Boundary Body Extractor
To extract JSON data the best option is native JSON Extractor:
http://jmeter.apache.org/usermanual/component_reference.html#JSON_Extractor
Regarding your precise issue, a better regexp would be:
access_token":"([^"]+?)"
It seems that you have optional white space after :
Regular expression:
access_token":(\s*)"([a-zA-Z0-9.\-\_]*)
Template change to use $2$

Sonar Issues/search API JSON result has single quotes

I'm using the sonarQube 6.4 web api to get a list of issues
http://sonar-server:9000/api/issues/search?componentKeys=Project_key&sinceLeakPeriod=true&statuses=OPEN,REOPENED&types=BUG
This gives me a Json object which has single quotes,
..."message":"Make this function anonymous by removing its name:
'function() {...}'."...
Because of that highlighted content in the JSON I'm unable to process the JSON from Groovy.
Is the JSON returned by the sonar is valid ?
if so, is there any way to process this kind of JSON in groovy.
Let me know if the full JSON object is needed.
According to http://json.org/ and https://jsonformatter.curiousconcept.com/ the JSON response is valid. Single quotes and brackets {} must not be escaped. The issue comes from your Groovy parser.

How do I pass json in the url of a REST request?

I am creating a kafka broker in a cluster by sending a request to the url. According to the api it says that I can add additional options to my broker in the form /api/broker/<cli command>?broker={broker-expr}&<setting>=<value>, however the setting that I need to set has json as its value. How would I do this?
I've tried quite a few different ways of writing it at none of them work. The json value is meant to be
{
"period":"10s"
}
I've tried
/api/broker/remove?broker=0&stickiness={"period":"10s"}
/api/broker/remove?broker=8&stickiness={period:10s}
/api/broker/remove?broker=8&stickiness="{period:10s}"
Update:
I've tried encoding the url but it still doesn't work. Everything is decoded except for the :.
The string I enter for the json: %7B%22period%22%3A%22600s%22%7D
This is what it ends up as after I send it.
How do I encode a : ?
Only the first option you suggested is correct JSON. However, the JSON will need to be encoded.
Encoding just the JSON part results in %7B%22period%22%3A%2210s%22%7D
Check out the following site for more on URL encoding
http://www.w3schools.com/tags/ref_urlencode.asp

Json file has special char but still wanted to Parse Json in to object in C#

I have following JSON but need to parse it into C# object.
But I am getting message that JSON is not well formatted.
{
[
"<a target="\"WindowA1\"" href="%5C%22http: //www.google.com/test%5C%22">1234568</a>",
"<a target="\"WindowA1\"" href="%5C%22http: //www.google.com/test%5C%22">1234568</a>"
]
}
How to handle the " inside the " while parsing the json file.
That "JSON" is totally broken. You don't parse broken JSON. You go to the amateurs who tried to produce JSON and failed miserably doing it, and tell them off and make them fix it.
If that doesn't work then you tell your boss to make them fix it.
I'll repeat that: You never, ever parse broken JSON data.