POSTMAN COLLECTION RUNNER: passing the all body post request as a variable? - variables

I have a POST request template - instead putting all the JSON body i put a variable: {{bodyRequest}}
now i have a json file that looks like this(Below code bloc) that i upload in my collection runner as data json: my intention is to fetch {{bodyResponse}} from the iteration and make the post call in the api.
[
{ "{{bodyRequest}}":
{
"order": {
"order_date":"{{$timestamp}}",
"order_number":"{{$guid}}",
"reference":"Scenario1",
"destination":
{
"name":"test",
"phone":"00000",
"email":"test#test.com",
"company":"My Company",
"building":"My Building",
"street":"my street",
"suburb":"my sububr",
"post_code":"my postcode",
},
}
}
}
]
Then i click run
Open Collection Runner
Add Data file in Format JSON (above in code)
declare it as Json
run collection
Error Log
Request Body:"{{bodyRequest}} "
instead the all payload
thank you so much
Franco

Related

expo camera react native

I am using the expo camera feature to submit scanned images. I have used TakePicutreAsync and have a base64 image. The scan is working fine. But at the time of submitting images, there following is the server error when I try to send a HTTP POST request in try catch block,
Cannot read properties of undefined (reading '1')
and on front end it errors the partial request body (everything minus the features, see below) and that is the error object from which I can make no sense of the error.
I am using formData to form my request as below:
const body = {
frontImg: frontImageBase64,
backImg: backImageBase64
}
var obj1 = {"content": JSON.stringify(body)};
var obj2 = [{"type": "LABEL_DETECTION"}];
formData['image'] = obj1;
formData['features'] = obj2;
Here is the complete request formed ( part of which is spit out as error body from try(POST Request) catch block
FormData {
"_parts": Array [],
"features": Array [
Object {
"type": "LABEL_DETECTION",
},
],
"image": Object {
"content": "{\"frontImage\":\"/9j/4AAQSkZJRgABAQAAAQABAAD/4g...
}
}
What could be going wrong in submitting images or how do I debug with the error message being same as the request body with just image property and not features and nothing else?
Below is the error object body for reference.
error Object {
"config": Object {
"adapter": [Function xhrAdapter],
"data": "{\"_parts\":[],\"image\":{\"content\":\"{\\\"frontImage\\\":\\\"/9j/4AAQSkZAAAAA...

Trying to Upload .dat.gz file as as a base64 string using Jmeter http

I have to send a https rest API request through jmeter
body of the request :
{"auth":{"token":"${SessionID}"},"clientGUID":"B0DC2BE4-D744-45c6-AEF6-EBEF319A336B","taskID":"${TaskID}","chunkID":"1","chunkSize":3375134,"fileName":"${curFileTime}downloadLogsBig.dat.gz","bytes":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
where XXXX is the byte array of file. Need help achieve this with the best method do this
byte[] fileContent = Files.readAllBytes(uploadFile.toPath());
uploadReq.setBytes(fileContent); --> Java to set XXXX
You can try amending your request payload as:
{
"auth": {
"token": "${SessionID}"
},
"clientGUID": "B0DC2BE4-D744-45c6-AEF6-EBEF319A336B",
"taskID": "${TaskID}",
"chunkID": "1",
"chunkSize": 3375134,
"fileName": "${curFileTime}downloadLogsBig.dat.gz",
"bytes": "${bytes}"
}
and populate the "bytes" using JSR223 PreProcessor and the following Groovy code:
vars.put('bytes', new File('jmeter.sh').bytes as String)

How to POST json parameters from Postman to Jenkins?

I need to call a Jenkins job using its API through Postman. This job requires parameters (HOST, VERBOSITY and PMSP).
Auth works using Jenkins token and header Content-type:application/json is used.
I tried to call the endpoint https://jenkins_server/job/job_name/build/api/json adding the following body to the request but the result is Nothing is submitted, and the job doesn't run.
I tried to call the endpoint https://jenkins_server/job/job_name/buildWithParameters/api/json adding the same body. I get 201 Created (job is running) but no parameters are given to the job.
{
"parameter": [
{
"name": "HOSTS",
"value": "[linux]\n1.2.3.4"
},
{
"name": "VERBOSITY",
"value": "vv"
},
{
"name": "SANS_PMSP",
"value": true
}
]
}
Is my JSON well constructed ? Which endpoint do I need to call ?
If it's Postman that you would like to focus on, you can import the curl command straight into the application.
This creates a new request for you to use and it populates this request, based on the details in the command.
From here, you should be able to add your own URL and point this at the location you need.

Get Method is not working inside App if URL contains .info?

I am making a simple GET Method inside the APP , But its Not Working on some URL..
For Eg :
https://lievensberg.webcamconsult.com/wachtkamer/ZwXIk9KcYvMBFeJWiSeUQQ.json . - this is working (contains .com)
https://soa-webcamconsult.sense.info/wachtkamer/pk3rs51FpFUQkrHOJ0uBHg.json - this is not working (contains .info)
Both URL is Working Perfect in Browser...!
I am using AFNetworking, Any one can Help Me Please ?
This is the Call Method , Url given below
//https://soa-webcamconsult.sense.info/wachtkamer/pk3rs51FpFUQkrHOJ0uBHg.json
NSDictionary *header = [NSDictionary dictionaryWithObjectsAndKeys:#"application/json",#"Content-Type", #"application/json", #"Accept", #"iPhone",#"User-Agent",nil];
NSLog(#"url---%#",url);
NSLog(#"header---%#",[Utilities printJson:header]);
[SSNetworkClient initServerCallWithURL:url requestMethod:SSRequestMethodGET requestSerialize:YES headers:header imageData:nil imageDataName:nil parameters:nil success:^(id object) {
completionBlock(YES,object);
} failure:^(id object) {
failureCompletion(NO,object);
}];
In you response of second url you are getting invalid json and which should be like this,
{
"status": {
"code": "on_time",
"message": "U bent op tijd",
"content": "Uw afspraak begint om *|afspraak_tijd|* ."
},
"slave": {
"name1": "Dhr. sunny",
"name2": "Meneer sunny"
},
"master": {
"name1": "Mr beheerder"
},
"push": {
"origin": "pubsub.pubnub.com",
"pub_key": "pub-c-a6ca4c51-0a6f-475d-8f93-f53f48ba117b",
"sub_key": "sub-c-97578f62-3587-11e3-be49-02ee2ddab7fe",
"uuid": "sunny-5a323ac22cacff0004c2a717",
"channels": ["5a29524f2b4faa000470384a", "5a323ac22cacff0004c2a717"]
},
"lobby_message": "",
"contact_info": "/dyncontent/pk3rs51FpFUQkrHOJ0uBHg"
}
Above is the correct json which you will need to improve in your api response
And if you wont verify just create the json file with above json it will work perfectly with browser and with your .info api response json it won't work so you need to improvise your .info json file response
My Mozilla browser Quantum version response,

How to pass a file to an API from Azure Logic App

I have a simple Logic App. The trigger is on New file (ex: Dropbox, OneNote, etc.)
I want to pass the filename and the fileContent to a API APP (web Api).
But I got error, or worse the content is null once in the API!
The API is in C#.
How do you pass a file (ex: pdf, png) to and API from Logic App
UPDATE:
In Logic App here my action code:
"UploadNewFile": {
"inputs": {
"method": "post",
"queries": {
"filedata": {
"fileName":"#triggerOutputs()['headers']['x-ms-file-name']",
"fileContent":"#base64(triggerBody())"
}
},
"uri": "https://smartuseconnapiapp.azurewebsites.net/api/UploadNewFile"
},
"metadata": {
"apiDefinitionUrl": "https://smartuseconnapiapp.azurewebsites.net/swagger/docs/v1",
"swaggerSource": "website"
},
"runAfter": {},
"type": "Http"
}
In my API App, If the function is declared like this filedata is null
[Route("api/UploadNewFile")]
[HttpPost]
public HttpStatusCode UploadNewFile([FromBody] string filedata)
And if I don't add the [FromBody] like that I got an error.
[Route("api/UploadNewFile")]
[HttpPost]
public HttpStatusCode UploadNewFile(string filedata)
Yes you can send binary content to your own API in a few different methods. Our out-of-the-box actions use this as well.
If you want to send the binary contents as the request body
For example, an outgoing request from the Logic App could have binary content and a content-type header of image/png
In this case the swagger for the body of your request should be binary - or:
{ "name": "body",
"In": "body",
"Schema": {
"Type":"string",
"Format": "binary"
} ... }
That should tell the designer that the request body is binary content. If a previous action or the trigger had binary data (e.g. "When a file is added to FTP") and you used that output in the body, it would show up in your custom API inputs as:
"Body": "#triggerBody()"
Notice there are no { and } on the expression (string interpolations) which would convert the binary content to a string. This would send an outgoing request to the connector with the binary content - so your controller just needs to accept binary content and honor the content-type header as needed.
If you want to send binary content in a JSON request
Sometimes you don't want to send binary as the full request, but as a property of another object. For instance a person object may have a name, address, and profile pic all in the request body. In this case we recommend sending the binary content as base64 encdoded. You can use "format": "base64" in swagger to describe a property as this. In code-view would look something like:
"Body": {
"Name": "#triggerBody()['Name']",
"ProfilePic": "#base64(body('Dropbox'))"
}
Hope that helps. Let me know if you have any questions - here is an article on how logic apps preserves content-types as well.
I found how to to it.
I needed to pass the filename in the querystring and the file in the body of the HTTP Request. Today, it's not possible to do it using the design view so you need to go in code view.
In the Logic App code
"queries": {
"fileName": "#{triggerOutputs()['headers']['x-ms-file-name']}"
},
"body": "#triggerBody()"
In the API App code
public HttpResponseMessage UploadNewFile([FromUri] string fileName)
{
var filebytes = Request.Content.ReadAsByteArrayAsync();
[...]
}
A more detailed explanation can be found in this blog post:
http://www.frankysnotes.com/2017/03/passing-file-from-azure-logic-app-to.html