As all Postman collections are basically .json files it's quite difficult to review code written in Postman via code review tools.
At the moment I continue to review such .json files on GitHub, however, it's not quite convenient.
For instance, here's some JS code sent for review in .json format
"listen": "test",
"script": {
"id": "e8f64f04-8ca5-4b5a-8333-1f6bde73cf0c",
"exec": [
"var body = xml2Json(responseBody);",
"// const resp = pm.response.json();",
"let resp = body.projects;",
"var b = \"New_Poject_e2e\"+pm.environment.get(\"random_number\");",
" console.log(b);",
"for (var i = 0; i < resp.project.length; i++)",
"{",
" if (resp.project[i].name === b)",
" {",
" console.log(resp.project[i].id[\"_\"]);",
" pm.environment.set(\"projID\", resp.project[i].id[\"_\"]);",
" }",
"}",
""
],
"type": "text/javascript"
}
Is there an effective way to carry out code review for Pre-request scripts, Requests, and Tests for Postman Collections?
Have you tried creating a fork of the Collection?
https://learning.getpostman.com/docs/postman/collections/version_control/#forking-a-collection
You can make changes in the Forked Collection and then Merge them - Before merging you get taken to the web view which might make these diffs easier.
Related
{
"id": 115084015,
"from": "help#email.ncloud.com",
"subject": "Verify Code",
"date": "2022-12-27 19:53:45",
"attachments": ,
"body": " Verification Code : 9906 Enter the code to sign up! Keep this code to yourself, and no other action is required. "
}
how do I want to retrieve the submitted code that appears from the json response?
I want to get just the response code to put in the variable value
I assume that you want to get 9906 from body part.
const res = pm.response.json();
let body = res.body;
const regex = /\d{4}/gm;
//console.log(regex.exec(body)[0]); //9906
pm.environment.set("code", regex.exec(body)[0]);
My backend is on Laravel and App is on Flutter
I have found this FCM WITH AWS
However my question is how to send GCM data showed by #Nathan using AWS Sdk/Api
{
"GCM": "{ \"notification\": { \"title\": \"test title\", \"body\": \"test body\" } }"
}
My message is delivering to my app however I can't set few variables such as
contentAvailable
Also not sure how to send sound type.
Thanks for the help
I have managed to make it work even it's partially for now.
This works for me
$GCM = json_encode(json_encode([
"notification" => [
"content_available" => true,
"body" => "Don't forget to put your fogo bin outside",
"title" => "Hello"
],
]), JSON_UNESCAPED_SLASHES);
$message = '{ "default": "test", "GCM":' . $GCM . ' }';
I have not managed to set contentAvailable and not sure how to send sound in there but getting there so if anyone can help me with remaining tasks will be highly appreciated :)
I am trying to create a voice bot with aws lex.
In that one of the intents response is "Your incident INC11111111 is closed"(text).
The above response is coming from a lambda function. Please check the code below.
let response = (event, data) => {
let lambda_response = {
"sessionAttributes": {
"incidentNo": event.currentIntent.slots.INCIDENT_NO,
},
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "Hi " + data["User ID"].split('.')[0]+", Your Incident Number " + "INC"+event.currentIntent.slots.INCIDENT_NO+ " is ," + data["Status"]
},
}
};
return lambda_response;
};
Ex Incident No: INC11111111
But the voice output is "your incident INC 1 crore 11 lakhs 11 thousand 1hundered eleven is closed".
What I am expecting is "Your incident INC ONE ONE ONE ONE ONE ONE ONE ONE is closed.
thank you in advance.
You need to utilise SSML(Speech Synthesis Markup Language)
Using SSML tags, you can customize and control aspects of speech, such as pronunciation, volume, and speech rate.
There are a variety of directives that you can use in SSML to pronounce things differently. In your case say-as directive can be useful.
As per the question edit, try these changes
"message": {
"contentType": "SSML",
"content": "<speak> Hi " + data["User ID"].split('.')[0]+", Your Incident Number <say-as interpret-as="characters">" + "INC"+event.currentIntent.slots.INCIDENT_NO+ "</say-as> is ," + data["Status"] +"</speak>"
},
Related reading : Announcing Responses Capability in Amazon Lex and SSML Support in Text Response
i'm newbie here and newbie also using postman.
I'm trying to use environments to store values from responses and use them to the next request. I found some examples on the web and i use them.
I managed to store the first value in a environment but not the 2nd, 3rd, in the same request. I tried many different ways to write the tests but without success
My tests' code is this:
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("clientID", jsonData.LoginClientID);
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("COMPANY", jsonData.objs.data[0].LoginCompan
Response was this:
{
"success": true,
"clientID": "abcd",
"objs": [
{
"COMPANY": "1",
"BRANCH": "1",
"MODULE": "0",
}
],
"ver": "5.00.518.11143"
}
Running the POST request the value of clientID is stored in enviroment's value but not COMPANY
Any advice ?
Thanks Eddie
Just remove the data part of the code when setting the variable. You're just after the list of items in that objs array, not sure where data comes into it.
For example, from your code:
jsonData.objs[0].LoginCompan
More information about extracting values from a response body can be found here:
https://community.getpostman.com/t/sharing-tips-and-tricks-with-others-in-the-postman-community/5123/5
declareUpdate();
//get Docs
myDoc = cts.doc("/heal/scripts/Test.json").toObject();
//add Data
myDoc.prescribedPlayer =
[
{
"default": "http://www.youtube.com/watch?vu003dhYB0mn5zh2c"
}
]
//persist
xdmp.documentInsert("/heal/scripts/Test.json",myDoc,null,"scripts")
You're looking to add a new JSON property. You can do that using a REST Client API request, sending a PATCH command. Use an insert instruction in the patch.
See the note in Specifying Position in JSON, which indicates that
You cannot use last-child to insert a property as an immediate child of the root node of a document. Use before or after instead. For details, see Limitations of JSON Path Expressions.
Instead, your patch will look something like:
{
"insert": {
"context": "/topProperty",
"position": "after",
"content":
[
{
"default": "http://www.youtube.com/watch?vu003dhYB0mn5zh2c"
}
],
}
}
where topProperty is a JSON property that is part of the root node of the JavaScript object you want to update.
If that approach is problematic (for instance, if there is no topProperty that's reliably available), you could also do a sequence of operations:
retrieve the document
edit the content in Python
update the document in the database
With this approach, there is the possibility that some other process may update the document while you're working on it. You can either rely on optimistic locking or a multi-statement transaction to work around that, depending on the potential consequences of someone else doing a write.
Hey #Ankur Please check below python method,
def PartialUpdateData(self,filename, content, context):
self.querystring = {"uri": "/" + self.collection + "/" + filename}
url = self.baseUri
self.header = {'Content-Type': "application/json"}
mydata = {
"patch":[{ "insert": {
"context": context,
"position": "before",
"content": content
}}]}
resp = requests.patch(url + "/documents", data=json.dumps(mydata),
headers=self.header, auth=self.auth, params=self.querystring)
return resp.content
I hope this can solve your problem.