How to put array parameter into fromdata with postman - api

How can I pass this form data in postman?
I have tried this way and did not work

https://stackoverflow.com/a/16104139/6793637
you should check this post and https://laracasts.com/discuss/channels/javascript/formdata-append-javascript-array-jsonstringify-how-to-cast-as-php-array?page=1
i think you should use JSON.parse(FOrmadata.field) in the server to convert the passed formData field to array

Related

Why I only getting id's back in response? IGDB api

I already read the documentation and I think I am making the simplest request in the correct way, but it always returns only the IDs, instead of all the fields of the games
Documentation example: Documentation Example
The request header is fine. I know this because I can get the expected request if fields = * as querystring
this is my request:
You have to provide the fields you want inside the body.
Like this:
fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collection,cover,created_at,dlcs,expansions,external_games,first_release_date,follows,franchise,franchises,game_engines,game_modes,genres,hypes,involved_companies,keywords,multiplayer_modes,name,parent_game,platforms,player_perspectives,rating,rating_count,release_dates,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;"

Is there any way to store array/list as variable/parameter in constructing an API in Postman?

I'm trying to parameterize a url in Postman and loop over that list to call multiple APIs one after another and append the JSON bodies.
For example:
if the url is GET https://location/store/{{user_id}}/date
and
user_id = ['1','3','5','2','6','8']
then how do I store user_idas a variable such that request can loop over each user_idin the url and generate an appended JSON body?
You can use data files. Store the user id values into a csv or JSON file and call that file in to your collection runner. The headers of the csv files can be used as variables names. please see the details of this approach in the below link
https://learning.postman.com/docs/postman/collection-runs/working-with-data-files/

I want to pass the header value in methods

Scenario : I need to verify the logs response on server on the basis of Tracking-Id.
I had passed the tracking-id using 'header.js' file, here i define metod which get the unique UUID for every request and passed in header.
Now I need that header value to passed in some method to get logs only for specific Tracking-Id
Is there any way to achieve this in karate?
Yes, you can use karate.set('someVarName', uuidValue) in JS and then back in the feature you will be able to: * print someVarName.
EDIT: please see this commit for an example: link

Mule: forward GET request with query parameters as POST request with json body

My app receive GET requests with URL query parameters. I would like to transfer this request to another app as POST request. I want that the query parameters will appear in the POST request inside the body as json.
Input GET url for example: http://localhost:8081/?name=John&age=30&gender=male
Expected POST json payload: {"name":"John", "age":30, "gender":"male"}
I think that I should use 'Data Mapper' for that, yet I failed to do so.
In the 'input' section I define the source to be - Inbound Property - http.query.params and type Map<String,String>.
In the output section I want the type to be json.
I can't debug/print the result of this mapping so I can't see what is the outcome of my definition. Is this the correct definition?
How do I define the parameters from the URL to be inserted into the map and be transformed into json?
No need to use DataMapper for such a simple transformation. Instead use a MEL expression transformer to create a map out of the query parameters, then add an object-to-json-transformer to serialize this map to JSON.
For example, this creates a map with the 'name' query param in it:
<expression-transformer
expression="#[['name':message.inboundProperties.'http.query.params'.name]]" />
Just add all the params.

CakePHP 2.0 give empty response using _serialize

I'm using the serialize key to output data in json format. Is there a way to output nothing, just an empty response with application/json as content-type? I've tried null, an empty string and an empty array as a serialize value but nothing seems to do the trick.
Reference: http://book.cakephp.org/2.0/en/views/json-and-xml-views.html#using-data-views-with-the-serialize-key
You'd have to not use the _serialize method and instead use a custom view. See: http://book.cakephp.org/2.0/en/views/json-and-xml-views.html#using-a-data-view-with-view-files
You can make all your actions use the same view file via $this->render('my_custom_view'); instead of creating a new view file for each.