I have an IOT service in aws and it posts data to a pipeline. The data posted is in the form of string and the body contains just the string as follows:
"{\"Time_Stamp\":1662449255,\"IMEI\":\"860987053151997\",\"BPID\":\"0\",\"Warn\":\"1000\"}\r\n"
I am parsing the data to JSON and then extracting it on my server but I want to know that if I wanted to test this in postman then how do I make a request? How to send the following data as body so that I could parse it locally for debugging?
First and foremost select your request type like - POST, GET, etc
then select Body and under the body select the 4th option raw
And after the 5th option there is a dropdown with text, javascript,JSON
so, select JSON and paste your JSON data and call your API
I think the solution was similar like this documentation
You can type your JSON, into the raw (JSON). And it will be seen like this picture.
If you still need to learn more, let's take an exercise session with this collection.
Thank you
Related
I cannot seem to be be able to use a REST-source with the the body as dynamic content from a previous lookup-activity. The body content in the REST API call will be messed up with "" and "\n" characters. I noticed data factory automatically adds braces to dynamic content:
Removing the braces from the code view results in an error when running the pipeline. I have tested the same API call with a web activity, in which the body will be formatted correctly:
However, I don't know how you can save the response as a file from a web activity. In recap, I want to dynamically pass the Body to a REST API and save the response as a json file. How should this be achieved?
I haven't used this scenario myself, but two things come to mind:
1) Assuming the body needs to be JSON, so you may need to convert the lookup value [which I assume is a string] using the json expression. Something like
#{json(activity('Lookup1').output.value)}
2) Under additional headers, you may need to add an entry to specify Content-Type: application/json
I am new to jmeter, I am using jmeter to test e-commerce website.
I have manage to script one scenario, which is to add a product in basket and test the response time.
Now, I have observed that when i click Add button on UI, their are two requests which are getting POSTED.
for eg: stocks are updated.
As of now, I have copied the BODY from stock and pasted in jmeter sampler, but in future i may change the Sales order and update scenario, hence i want to store this Body data(Stock request which is updated) of this request dynamically, as it will change corresponding to sales order number im providing.
The problem is I am not able to store the BODY data dynamically(Only if i change the sales order here).
I know i can use pre processor in this matter, but could anyone help me with the code to get the BODY data from the request and store dynamically before sending the sample.
Basically I need a solution where I am just updating my sales order number and rest of the things will be taken care dynamically, in my case the POSTING of Body data for updating the STOCK.
Thank you in advance!
See basically, you're talking about Correlation. As I can understand from your concern. You need the data for the product added to the cart. Which needs data from prev request. This can be easily managed by generating two requests. Extracting from first and using that info for the second one. This will not involve any hardcoding and will work for you in an efficient manner.
Something like:
vars.put('bodyData', sampler.getQueryString())
should do the trick for you, if you put this code into a JSR223 PreProcessor and add this PreProcessor as a child of the HTTP Request sampler which body you need to store - you will be able to access the request body as ${bodyData} later on where required
In the above example:
vars - stands for JMeterVariables class instance
sampler - is for HTTPSamplerProxy
More information: Top 8 JMeter Java Classes You Should Be Using with Groovy
It seems that docusign only supports downloading the signed documents as PDF instead of JSON.
I need to 'read' the filled fields of the documents (the document has some fields to fill in).
I can upload the document as JSON and it gets parsed, so why can't I donwload it as JSON?
How do companies normally handle the field values?
Thanks!
You don't need the actual PDF document to get the values, you need to parse the call coming back from DocuSign since that has total envelope data. The webhooks for notification contains the data and you can parse that to retrieve the envelope data.
Do you know if its also possible with a GET call instead of the webhook? It could be the server is down etc, so I can't imagine DocuSign does have something like GET:envelope/:id/data or something.. But really cannot find anything like it
Yes. You can either use a GET call (included below) any time you want to get envelope data or you can set up the webhooks so that DocuSign will send you updates whenever it has one!
The following GET call retrieve envelope data from {{envelopeId}}. By parsing the response from the call you can retrieve all information that was filled on the envelope.
{{baseUrl}}/envelopes/{{envelopeId}}/recipients?include_tabs=true
I hope this helps.
P.S. Summarized our comments to have a complete answer.
The PDF format is, for lack of better words, a complicated jumble of compiled data that can be difficult to parse. What it appears docusign will do is take the data provided and fill the PDF document fields that are previously identified.
With docusign returning the PDF, you will need to parse the PDF input fields to receive the field values. There are several libraries that can be used to parse the various form fields and do what you would like. Check out:
https://www.npmjs.com/package/pdfreader
https://www.npmjs.com/package/pdf2json
I am sure there are more that would work for you as well if you look around if these don't work for you.
I know Background keyword is available for running a common steps before running each scenario. Likewise is there anything like "After" keyword is available for the commons steps after each scenario, not the logical steps in java code like after hooks, i mean in gherkin steps itself. i need like below
Background
Given I use the API header information
| Content-Type | application/json;v=3 |
And I connect to postgresql
Scenario Outline:
And I get the "Request" payload from "5NB_CARD-A_Request" file for the scenario "CardA_Scenario1"
And I store the input payload individual field details for database validation
And I form a client with this resource url "/transaction"
When I make a POST call and capture the response
And I get the "response" payload from "5NB_CARD-A_Response" file for the scenario "CardA_Scenario1"
Examples:
| HTTPCode |
| 200 |
After
Then I validate the output response with expected data
And I verify the HTTP error code is "<HTTPCode>"
And I fetch and validate latest created data from "transaction" table
And I validate the created card is inserted into "field" table
Short answer, you can probably use an After hook, more on this here, but it's not recomended for your case. BDD is used for communication with non-technical stakeholders
From how you've written the scenario outline, it seems that this only runs once and if the response if different form 200, then the last 2 steps will fail (or even the first Then).
If the only thing you need to check is the happy flow, in which the response is 200, there is no need for Scenario Outline with Examples. Simply create one scenario.
Background
Given I use the API header information
| Content-Type | application/json;v=3 |
And I connect to postgresql
Scenario: Happy flow
And I get the "Request" payload from "5NB_CARD-A_Request" file for the scenario "CardA_Scenario1"
And I store the input payload individual field details for database validation
And I form a client with this resource url "/transaction"
When I make a POST call and capture the response
And I get the "response" payload from "5NB_CARD-A_Response" file for the scenario "CardA_Scenario1"
Then I validate the output response with expected data
And I verify the HTTP error code is "200"
And I fetch and validate latest created data from "transaction" table
And I validate the created card is inserted into "field" table
If you are expecting to add more response codes then it might be a good idea to rewrite the scenario outline in a different way. There is no need for After keyword for your verification (Then steps). You are writing them only once anyway, when using scenario outline.
Background
Given I use the API header information
| Content-Type | application/json;v=3 |
And I connect to postgresql
Scenario Outline:
And I get the "Request" payload from "5NB_CARD-A_Request" file for the scenario "CardA_Scenario1"
And I store the input payload individual field details for database validation
And I form a client with this resource url "/transaction"
When I make a POST call and capture the response
And I get the "response" payload from "5NB_CARD-A_Response" file for the scenario "CardA_Scenario1"
Then I validate the output response with expected data
And I verify the HTTP error code is "<HTTPCode>"
And I fetch and validate latest created data from "transaction" table
And I validate the created card is inserted into "field" table
Examples:
| HTTPCode |
| 200 |
Keep in mind that you will need to manage the last steps differently if you are adding more response codes.
It also might be a good idea to hide details such as | Content-Type | application/json;v=3 | and manage them inside the step definition.
Update:
What I gathered from your comment is that you want to have those last 4 steps (Then steps) written only once inside a feature file and all the scenarios to use them.
As far as I know, there is no After which can execute the verification steps same as Background does for the preconditions, in the Gherkin language.
There is a way to simplify this, but it reduces reeadability. For example, if you have 10 scenarios and 2 scenario outlines that use the exact same four Then steps, then you could try nesting all of them in a more general one and if steps come from different step definistion files, then you could use picocontainer to group them and reduce the number how many times you call them inside the feature file. More details here .
Problem is that your Then steps are a bit complicated to be written in just one or even 2 simpler steps, because you have 3 params and 5 verifications.
To conclude, I think it's better to have them written for each scenario / scenario outline. I would be difficult for another person to look at the feature file and not see any Then, only to find them at the bottom. A better way would be to try and group more scenarios in scenario outlines, so the steps don't repeat that much.
Hope it helps!
I'd like to know if this is even possible. And if it is possible, what the security ramifications would be.
I want to use Javascript to build a dynamic URL to query a Parse-Server database.
It appears that it might be possible based on an earlier Stackoverflow question here and a Node.js doc here
Here's how I envision it working....
So, a user would be sent (via email/Twitter/etc) a link which was created by above method. Once the user clicked on that URL link, the following would happen automatically:
Step #1: User's system would automatically submit a parse-server query.
Step #2: On success, the user's browser would download a web page which displayed the query results.
step one create the pointer value ie the query pseudo-semantic
step 2 insert the pointer value to a text-type field in parse cls=clazz
step 2b mailgun a msg containing a link like :
express.domain.com/#!clazz/:yALNMbHWoy - where 'yA...oy' is oid of pointer row in parse/clazz table
Note that the link is an abstraction only. Its a uri first to express/route && function that will simply get a row from parse.clazz. That row contains the semantic for making a parse query to get back the full DB compliment to pass along to the node template setting up the html ...
in your node/router GET/clazz/:oid will lookup that Parse row in parse/clazz, using the pointer/text value to format a 2nd, Parse query. The query response from the 2nd parse.qry is your real meat ... This response can be used by the express template formatting the html response to orig request on "express.domain.com".
where u ask "download web page" .. that is simply node's RESPONSE to a GET on a route like "GET/clazz".