I don't know much about how to use an API, and I am just trying to get a basic understanding so I can use the Timekit.io API in a JS app I am going to build, so to start I though I should try and use postman to learn how to send a request. In the Timekit documentation for finding a time from a resource ie: a persons calendar they say to use this curl command.
curl --request POST \
--url https://api.timekit.io/v2/findtime \
--header 'Content-Type: application/json' \
--user :live_api_key_7nzvc7wsBQQISLeFSVhROys9V1bUJ1z7 \
--data '{
"resource_ids": ["78a4d873-2a68-41c6-bdd4-c0ca5b35efd3"],
"filters": { "or": [
{"specific_day_and_time":{"day":"Monday","start":9,"end":13}},
{"specific_day_and_time":{"day":"Wednesday","start":10,"end": 16}}
]},
"future": "2 days",
"length": "30 minutes"
}'
I am trying to figure out what I put into postman itself so I get the correct Json values. So far I have selected a POST request with the url https://api.timekit.io/v2/findtime and a header with the key Content-Type and value application/json I have no idea where to put the user,data,rsource_ids,filters,future & length Here is a screenshot of my post man setup.
--user sets the authentication. If an authentication type is not specified, then it will default to Basic Authentication. In Postman, click the "Authentication" tab and from the "Type" dropdown, select "Basic Auth". You can then input the username and password into the appropriate fields. With the --user flag, the value should be <username>:<password>. So your case, there is no username specified, so I guess you don't need to input it, just use the api key for the password.
--data is the JSON request body. You can input this entire value (within the single quotes ') into the "Body" tab. Select the "Body" tab, and within the tab, select the "raw" radio button, and from the dropdown to the right, select "JSON (application/json)". Now just put the entire JSON into the text area.
{
"resource_ids": ["78a4d873-2a68-41c6-bdd4-c0ca5b35efd3"],
"filters": {
"or": [
{ "specific_day_and_time":{ "day":"Monday", "start":9, "end":13 } },
{ "specific_day_and_time":{ "day":"Wednesday", "start":10, "end": 16 } }
]
},
"future": "2 days",
"length": "30 minutes"
}
You could just drop the curl request straight into Postman via the Import feature, this would populate the whole request in the application for you.
In the top left of the application UI, select the Import button and then select the 'raw' text option (it’s the last one) - paste the curl request text into the text box. Once imported, that should do the rest for you, if it’s a valid format.
Related
I'm new with Postman,(until today never used it)
I want this API request to run through Postman (pretty output)
curl -X GET http://localhost/api/myapi/subnets/ --header "token: token"
Through Postman i can easily get this token:
http://localhost/api/myapi/user/
Output:
{
"code": 200,
"success": true,
"data": {
"token": "token",
"expires": "2019-09-13 19:29:55"
},
"time": 0.013
}
But i don't know how to pass --header "token:token" part to Postman
I tried a couple of suggestion from Stack Overflow but none seems to work.
In the header section you can add the header param you want:
just write in the "key" column.
The Authorization section is an easy way to add the common "Authorization" header. All others header should be added by "Headers" section.
The request in my image is the same of your curl command.
Found it on this link: https://www.quora.com/How-can-I-convert-cURL-code-to-Postman
http://localhost/api/myapi/subnets/?Authorization= token
I'm implementing a chat bot using messenger API. In a scenario like this, how to match answers with the question when both of them are in text message format. I can't use pattern matching here.
bot q1: How much is it?
user: 250
bot q2: How many?
user: 5
Is there a way to send meta data with a text message and get it as a post back. Is it required to store the last message.?
In the message field, in the same level of text field, you can define a field metadata, like defined in the doc (which has a 1000 character limit):
Custom string that will be re-delivered to webhook listeners
So it could be sth like that:
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"text":"hello, world!",
"metadata": "my meta data"
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
Im trying to send push with two criteria in where.
I make this so:
curl -X POST
-H "X-Parse-Application-Id: myappId" \
-H "X-Parse-REST-API-Key: myRESTApiId" \
-H "Content-Type: application/json" \
-d '{
"where": {“$and”:[{“deviceType": "winphone”},{”channels":{"$all":[“string1”],"$nin":[“string2”]}}]},
"data": {"alert": “String1 is comming”}
}' \
https://api.parse.com/1/push
Something like: https://parse.com/questions/rest-api-or-constraint-on-multiple-fields-using-where, but I getting error message: error code 107 - invalid JSON Parse
How can I send push notification for given device and for given channel with condition $all and $nin.
Thanks for your help!
Hipek
This error is likely being returned because your where value does not match the REST API spec. You will also want to make sure you are consistent in your use of double quotes as these can also lead to malformed JSON errors (e.g. do not use “ and ”, use ").
After fixing that, we end up with the following, which is still not valid per the REST API Parse docs:
"where": {
"$and": [
{"deviceType": "winphone”},
{"channels": {
"$all": ["string1"],
"$nin":["string2"]}
}
]
},
There's a couple of problems with your query:
$and is not a valid Parse REST API operator, and does not appear in the REST API docs. All constraints in a where query are implicitly ANDed, so this is unnecessary, anyway.
Your $all and $nin constraints over channels conflict with each other as there cannot be more than one such query per key. You may want to instead create a unique channel for those installations that should receive messages aimed at the string1 channel but not the string2 channel.
I have the following data, hoping to insert two worklogs at once into the same issue using the rest url:
curl -u jogbra:jogbra -X POST -k --data #data_holiday.txt -H "Content-Type: application/json" https://jira.myworkplace/jira/rest/api/2/issue/4371/worklog
data_holiday.txt contains:
{
"comment": "Christmas Day",
"started": "2015-12-25T08:50:09.423+0000",
"timeSpent": "8h 0m"
},
{
"comment": "Labor Day",
"started": "2015-09-07T08:50:09.423+0000",
"timeSpent": "8h 0m"
}
It only gets the first holiday (with or without the comma).
End goal is to automate the population of holidays. I don't see a way of making more than one worklog with one request, so should I resort to using a loop to call curl? If I do that, do I need to create one data file for each holiday?
I see from this post that google has solved this batch request issue with a "batch" endpoint. How would I accomplish this in jira?
Sorry, but in JIRA only one worklog per on request: https://docs.atlassian.com/jira/REST/latest/#d2e795
With facebook ad api, I can send a query to retrieve ad image information.
The following is the examples from facebook doc. https://developers.facebook.com/docs/reference/ads-api/adimage/v2.2
curl -G \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/act_<ACCOUNT_ID>/adimages"
curl -G \
-d "hashes=[%220d500843a1d4699a0b41e99f4137a5c3%22,%22012feg987e98g789f789e87976210983%22]" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/act_<AD_ACCOUNT_ID>"
Both calls work fine. But the problem is: they return just the array of image id and image hash, nothing else. Again, example from facebook doc. My test shows response with the same format.
{
"data": {
{
"hash": "0d500843a1d4699a0b41e99f4137a5c3",
"id": "16522000:0d500843a1d4699a0b41e99f4137a5c3"
},
{
"hash": "012feg987e98g789f789e87976210983",
"id": "16522001:012feg987e98g789f789e87976210983"
}
},
"paging": {
"cursors": {
"before": "NDIyNDAzMzc0NDY4NjQxOjE2...",
"after": "NDIyNDAzMzc0NDY4NjQxOmU5Njg..."
}
}
}
Ad Image objects are supposed to have 'url', 'width', 'height', properties. But I cannot retrieve anything more than id and hash, whatever I try.
Any way to get thumbnail url or other image properties using image hash or ad account id?
What I want to achieve ultimately is make a migration from manual management to automatic api based management, and get the url/properties of images already uploaded to facebook (to be saved in db and reused when necessary).
Like almost for all the Ad Objects, if you call an Ad Image endpoint without specifying any additional fields you only get and id and, sometimes, a few more parameters.
If you look carefully in the section "Create" of that page you'll find a list of fields; Add the needed one as a field param in your curl request.
Ex.
curl -G \
-d "access_token=<ACCESS_TOKEN>" \
-d "fields=id,url,whatever" \
"https://graph.facebook.com/act_<ACCOUNT_ID>/adimages"