Using gist.github.com, I am able to get JSON in raw form. However, when I edit the code, the url of the raw format changes. Can you suggest me a website which can do this bit for me? I would like to have a constant URL of my JSON code which I can edit it and have changes live on the same link.
{
"error": false,
"products": [
{
"name": "spiderman",
"image": "insert image link here"
},
{
"name": "superman",
"image": "insert image link here"
},
{
"name": "batman",
"image": "insert image link here"
}
]
}
The Url of gist changes with every version , if you want the url to stay constant
Try
https://jsonblob.com/
paste your response and save it will give url , just bookmark the url
get id from url and paste it in following url
https://jsonblob.com/api/jsonBlob/YOUR_ID
it will give raw response
Or else better get your own hosting , it will be good and more customizable
for your response
for changing data use
https://jsonblob.com/aa1ada56-6aed-11e8-b292-634b403e9ce7
for getting raw response use
https://jsonblob.com/api/jsonBlob/aa1ada56-6aed-11e8-b292-634b403e9ce7
Related
I am trying to get the description of group using getGroup API of AWS Cognito. I want to have the description of group in my JSON object, but it is not fetching the detail. Can someone help me with that?
Please look at documentation of AWS HERE.
As You can see response contains description of group.
{
"Group": {
"CreationDate": number,
"Description": "string",
"GroupName": "string",
"LastModifiedDate": number,
"Precedence": number,
"RoleArn": "string",
"UserPoolId": "string"
}
}
Please show us Your code, maybe we can find problem there.
I have some spring MVC based APIs which produces JSON/ XML which represents API output.
{
"data" :
{
"users": [
{
"id": "001",
"name: "abc1",
"type": {
"id": "P",
"name": "Permanent"
}
},
{
"id": "002",
"name: "xyz",
"type": {
"id": "C",
"name": "Contractor"
}
}
]
}
}
I'm passing a parameter with request as
url?fields=users.id, users.type.id
users.type.id is a sub-node in users node.
users node is an array.
Now, what I want to do is to filter those only properties and create the response based upon fields passed in the request.
So the response to above filter condition should be same structure and will only contain wanted fields with values.
I'm trying to build a flat map with keys with a dot notation so I won't lose the track to filter, then I'll rebuild the JSON again. I feel this approach is just unreasonable because Jackson has the .path and .with API's to check existing path. But the real challenge is to extract and create a new JSON which matches the response JSON.
I'm looking for some ideas to achieve this. I don't want to try any third party libs btw. I know some libs are there. I want to prefer Jackson way to do this.
Feel free to add or comment if you have a further ideas.
I was trying to implement mocking of POST REST call using Wiremock Standalone server. I am faced with a challenge like this, suppose the post body contains an "name" field and its value, the same value should be returned in the response of that POST call. My json file looks like this:
{
"priority": 1,
"request": {
"method": "POST",
"urlPath": "/primeSlots",
"bodyPatterns" : [ {
"matchesJsonPath" : "{ \"things\": [ { \"name\": \"794363\" }]
}"
} ]
},
"response": {
"status": 200,
"body": "{{$.things.name.value}}",
"transformers": ["response-template"]
}
}
so, I need to get the value , that is 794363,but using above approach not able to get it in the post response body.
I tried this too:
{
"request": {
"method": "POST",
"urlPath": "/transform",
"bodyPatterns": [
{
"matchesJsonPath" : "$.things[?(#.name =~ /[0-9]+/i)]"
}
]
},
"response": {
"status": 200,
"body": "{\"responseName\": \"
{{request.body.things.name.value}}\"}",
"headers": {
"Content-Type": "application/json"
},
"transformers": ["body-transformer"]
}
}
So my question is, even if i use a regEx, which matches with any number that comes in the request, how to give back the same number in the response using Wiremock standalone json file?
Thanks.
Today I was in the same situation like you and found a solution which I would like to share with you:
Create own class that extends ResponseDefinitionTransformer
Add Handlebar functionality in your own transformer class ( see https://github.com/jknack/handlebars.java how to do it )
(Optional) Append your own/other helpers e.g.
Arrays.stream(StringHelpers.values()).forEach(helper -> this.handlebars.registerHelper(helper.name(), helper));
Export your transformer customization as a separate JAR file
Create a start batch script to start up your WireMock standalone with your own transformer extension e.g. java -cp "-cp ".\lib\wiremock-standalone-2.5.1.jar;.\lib\customTransformer.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --extensions "your.name.CustomTransformer" (for linux use : instead of ; as classpath separator)
In case you have multiple transformers, just define all those using , (comma) as separator in the --extensions arg.
Unfortunately WireMock's response templating transformer doesn't currently break out the request body into a Map as would be necessary for what you're trying to do. The request body is just a single string.
The simplest way for you to enable this would probably be to write a Handlebars helper that implements JSONPath or some other mechanism for querying a JSON document, then registering this with the templating transformer when you initialise WireMock.
At some point I'll write handlebars helpers to do this kind of thing for XML and JSON, but that won't be for a while.
Using REST API in Java I am trying to update QC ALM. I am getting value in html format when I am trying to extract comment section for any Defect. So, if I want to add any comment, do I need to pass as HTML content with the previous comment or is there any other way?
I have tried by Just passing the comment but it removes all the previous comment and it does not show the person name who is updating the comment as it happens through GUI.
This would help someone who is new to HP REST API.
1. To find available API end-points,
GET /qcbin/rest/resouce-list
To get Users' full name
GET /qcbin/rest/domains/<domain_name>/projects/<project>/customization/users/<user_name>
To get defect comment, the below request fetches only Defect ID = 1 and outputs dev-comments field.
GET /qcbin/rest/domains/<domain_name>/projects/<project_name>/defects?query={id[1]}&fields=dev-comments
Sample JSON payload,
PUT /qcbin/rest/domains/<domain_name>/projects/<project>/defects/1
{
"Fields": [{
"Name": "dev-comments",
"values": [{
"value": "<html><body><span style=\"font-size:14px\">USER FULL NAME <USER_ID>, 2016-06-29:</span></font></b>\n<font color=\"#767676\" style=\"font-family:'hpsimplified-regular' , sans-serif\"><span style=\"font-size:14px\"> </span></font>Comment 1 \n</div> \n</body></html>"
},
{
"value": "<html><body><span style=\"font-size:14px\">USER FULL NAME <USER_ID>, 2016-06-29:</span></font></b>\n<font color=\"#767676\" style=\"font-family:'hpsimplified-regular' , sans-serif\"><span style=\"font-size:14px\"> </span></font>Comment 2 \n</div> \n</body></html>"
}]
}]
}
I wanted to create a service which can accept JSON as an input to my endpoint. eg.
[{ "name": "Ram","event": "processed" },
{"name": "Raj", "event": "click" }] .
Tried some of the possible ways, cloud endpoints are not supporting arrays or any array related types to use. I tried it to convert the json to string but it's not working for me.
Thanks in advance.
You seem to have an invalid JSON. Try validating it here. As you can see, you will encounter a parsing error.
Change all occurrences of “ with "
[
{
"name": "Ram",
"event": "processed"
},
{
"name": "Raj",
"event": "click"
}
]
and now you have a valid JSON.
More details on JSON can be found here.