How to pas ISO 8601 formatted date value in GET Request - api

I am working on lob.com letters API. Using Postman application to test the API, facing the following error:
Postman Application to test Lob's API
The parameter "date_created" want date value in ISO 8601. I am passing the value in specified format but api returns the response having error: "date_created must be an object".
Need help!

In pre request script compute current date and set it to environment variable then you can pass it in your request body. A bit of code will look like this:
Pre Request
var date = new Date().toISOString();
postman.setEnvironmentVariable("date",date);
Request Body
// Other attribs....
"date_created" : "{{date}}"

Related

Pass sql date from talend to Rest Api

I want to send a post request to the rest API which includes an SQL date format, when I try to send the request with YYYY-MM-DD format, its showing bad request. How to properly send the data.
you can do something like this below,
#PostMapping("/date")
public void date(#RequestParam("date") Date date) {
// ...
}
Explanation: It will pass date from post request.
you can also look at this documentation
I hope, it helps!

Data Factory Dynamic Content in REST API Call

I'm making an API call, where once I'm authorised I have to use a security token as part of subsequent calls. I'm using the variable "SecurityToken" to store the token.
Also as part of the call I need to pass a date parameter, which is the date from 14 days ago in YYYY-MM-DD format.
I've built this formula but it will not run, it stops the whole pipeline from running
Dynamic Content:
#concat('https://MyAPIUrl/api/daily/UK?key=',variables('SecurityToken'),'&date=formatDateTime(addDays(utcnow(),-14),'yyyy-MM-dd')'&currency_type=GBP&use_website_rounding=FALSE')
Error:
{"code":"BadRequest","message":null,"target":"pipeline//runid/8990bb14-27f8-43e5-b7c0-1741204ff645","details":null,"error":null}
Can you try this
#concat('https://MyAPIUrl/api/daily/UK?key=',variables('SecurityToken'),'&date=',formatDateTime(addDays(utcnow(),-14),'yyyy-MM-dd'),'&currency_type=GBP&use_website_rounding=FALSE')

Include request parameters in URL when using Postman

I need to fire some requests using Postman but I need to include the parameter in the URL.
What I need:
https://serveraddress/v1/busride/user/favorites/route/RanDOMid
What I currently can configure in Postman:
https://serveraddress/v1/busride/user/favorites/route/?id=RanDOMid
I do not control the server, so I need to work it out how to craft the request in Postman to accept the input data as part of the URL, not as parameter. How can I specify input data in Postman to get it included in URL?
Click on Manage Environment
Add variable as path with Initial and current value as RanDOMid
Add path to URL:
https://serveraddress/v1/busride/user/favorites/route/{{path}}
#User7294900's answer should do for you in case all you want to do is include a variable in your request URL.
However, if you want to actually generate a random ID for every request, you may use {{$guid}} or {{$randomInt}} directly in you URL as follows:
https://serveraddress/v1/busride/user/favorites/route/{{$guid}}
This will generate a random GUID every time your request is fired and the generated GUID will replace {{$guid}} in your URL.
or
https://serveraddress/v1/busride/user/favorites/route/{{$randomInt}}
This will generate a random integer between 0 and 1000 every time your request is fired and the generated integer will replace {{$randomInt}} in your URL.
Refer postman documentation for more details - https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables
Hope this helps!

How to convert to a web response from a record/data-frame

I have an application where I am returning a data frame/record. I want to return a web response, how should I convert it to. Tried dumping in son but didn't work using web.jsonresponse.
Here is the return type that I want to convert into web.response so that I can use the status field of response.
[<Record id='CORN' description='primary subject of interest'>]

ShopStyle API - How to Invoke an HTTP request

How do I Invoke an HTTP request with a particular URL and process the body of the response as XML?
Information Provided by ShopStyle:
HOW TO USE THE API:
Choose the method that returns the data your application needs. For example, the /products method is used to get products that match a given category or brand.Construct a URL for that method with the appropriate host, method name, and query parameters. Invoke the URL as an HTTP GET.
When the HTTP response arrives, extract the required data elements from the response's body.The rest of this document describes the details of constructing the right URL for each of the API methods. The XML format of the responses may be seen by clicking on the sample URLs shown for each method. The responses in JSON format contain identical information, just in a different format.
SHOPSTYLE API URLS
All ShopStyle API URLs have the following form:
http://api.shopstyle.com/api/VERSION/METHOD_NAMEpid=YOUR_API_KEY&format=FORMAT&...
The METHOD_NAME is taken from the list of methods in the various API shown at left (Press Link To View List of Methods-https://www.shopstylecollective.com/api/overview).
COMMON API PARAMETERS
All methods in the API accept these parameters:
API_KEY (my unique key is ******************)
pid Unique API_KEY string that is assigned to the caller. You can find your API Key on the Account Settings page.
FORMAT
The format of the response. Supported values are:
json - The response is in JSON format with UTF-8 encoding. This is the default if the parameter is absent.
xml - The response is in XML format with UTF-8 encoding.
jsonp - The response is in JSON format with UTF-8 encoding wrapped in a JavaScript method called padding. The padding must be specified with the query parameter 'callback'. Only single expressions (function reference, or object property function reference) are accepted as valid padding.
When set to 1 or 'true' the HTTP status will always be 200. Use the field "errorCode" in the response to detect whether the API Call was successful. By default, when an error occur the HTTP Status of the response will be different than 200
Again I am a beginner, so please provide detailed information on how to retrieve CATEGORY data (Examples: Dresses, Tops, Buttoms, etc) in XML format.**
Thank you!!!
Here's a simple example to get your started. Copy the code below and put it into a file, say "cat.php". Then run it by typing "php cat.php" at a command prompt (assumes you have php on your machine):
<?php
// don't show dom parse errors
libxml_use_internal_errors(true);
// grab the xml from the api
$response = file_get_contents("http://api.shopstyle.com/api/v2/categories?pid=TEST&format=xml");
$doc = new DOMDocument();
$doc->loadHTML($response);
// grab all the categories
$elements = $doc->getElementsByTagName('categories');
foreach($elements as $node){
foreach($node->childNodes as $child) {
// get the name out of the category
$nodes = $child->getElementsByTagName("name");
foreach ($nodes as $name) {
echo $name->nodeValue . PHP_EOL;
}
}
}