Intercom API (v2.0) search conversation not working - postman

I tried to search conversation from Intercom API using Postman but it always return server error message.
I just followed their API docs.
request url: POST https://api.intercom.io/conversations/search?query=updated_at>1590278400

The query should be in JSON format in the Body, not in the querystring like you do in your example:
{
"query": {
"field": "updated_at",
"operator": ">",
"value": 1590278400
}
}
In Postman it looks like this (note: don't forget to add your authentication)

Related

Google : contact search [Method: people.searchDirectoryPeople ]

I'm using google directory search API but i coudn't retrive the users names(firstName, lastName) details in response even after applying proper readMask
below is the request details:
{
"method": "GET",
"headers": {
"Authorization": "Bearer access_token",
"Content-Type": "application/json"
},
"uri": "https://people.googleapis.com/v1/people:searchDirectoryPeople?query=ajay&readMask=names,nicknames,addresses,calendarUrls,emailAddresses,organizations,phoneNumbers,photos,relations&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE"
}
NOTE: I'm getting the proper results with api, but issue is for some contact results, i'm not getting names(firstname, lastname) data/info in the response
If you are getting a "PERMISSION_DENIED" error, this means the access token you are using doesn't have the directory access scope:
https://www.googleapis.com/auth/directory.readonly
Which is required for accessing directory contacts.
Also your sources param should be:
sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT,DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE
and not
sources=DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT&sources=DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE
P.S.
It's a very bad idea to post real access-tokens in public posts, you should always redact secrets when you post your API requests online.

AWS API Gateway with Cognito Authorization never blocks requests even with invalid id tokens

I followed this AWS API Gateway doc and set up an authorization for my API with a cognito identity token. I tested my cognito id token in the API Gateway console, that works: It gives me the correct values, the sub and email values are correctly retrievd from the token:
testing the id token works
I then added the Authorizor to my Method:
my method request
But when I now test my method, still all requests go through (with or without identity token provided) when I send them from the test form in API Gateway (inside the method):
teting with no token or invalid token
I would have expected an "Unauthorized" or "Access Denied" response, instead I get 200.
I also tried setting "API Key Required" in Method Request to true and require an Autorization Header, but even then the request from above comes through with status 200:
setting API Key Required to true
I also added
"context" : {
"sub" : "$context.authorizer.claims.sub",
"email" : "$context.authorizer.claims.email"
}
to my mapping template, so the full template now looks like this:
{
"TableName": "myUsersTable",
"Key": {
"id": {"S": "$input.params('id')"},
"username": {"S": "$input.params('id')"}
},
"context" : {
"sub" : "$context.authorizer.claims.sub",
"email" : "$context.authorizer.claims.email"
}
}
but the log is always empty for sub and email (and the response status is still 200):
Tue Dec 29 10:35:46 UTC 2020 : Endpoint request body after transformations: {
"TableName": "myUsersTable",
"Key": {
"id": {"S": "testUser"},
"username": {"S": "testUser"}
},
"context" : {
"sub" : "",
"email" : ""
}
}
What am I doing wrong here?
For me it never worked when I tested it inside the API Gateway console. But when you use Postman, it should work (set "API Key Required" in Method Request back to false and delete that an Autorization Header is required, then deploy your API again and test it with Postman, putting your token into the request header like this:
Your mapping template for the sub and email values seems correct, too. I think the whole Authorization validation is just skipped when you use the API Gateway console to test, but I'm not sure. Use Postman instead, then it should work.
See also: https://medium.com/#chandupriya93/providing-authorization-to-api-gateway-with-cognito-identity-pools-af451fd3b532

SAP B1 Service Layer Login POST request gives error code -304 with an empty message

I'm trying to reach SAP Business One Service Layer APU via PostMan and Python (with requests module). However, when I try to POST to /Login endpoint to our Service Layer it gives me the following JSON result:
{ "error": { "code": -304, "message": { "lang": "en-us", "value": "" } } }
As you can see, it's an error code -304 with an empty message value.
The payload I'm sending is a text like this:
{"UserName":"my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}
I have tried this payload as well to /Login enpoint but with no successful result:
{"Username":"my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}
but this results in this JSON result:
{ "error": { "code": 102, "message": { "lang": "en-us", "value": "Invalid login credential." } } }
Can anyone, please, suggest what may be wrong here? I need to Login and then GET the Items from the DB.
Thank you in advance
The issue was that I needed to use a domain before the username. So, at the end, the working payload looks like this:
{"UserName":"my_domain\\my_username","Password":"my_password","CompanyDB":"NAME_OF_MY_DB"}

Telegram bot sendMediaGroup() in Postman - JSON-serialized array?

I'm using Postman app to interact with a Telegram bot api. I've sent photos using the sendPhoto() method, like this:
https://api.telegram.org/botToken/sendPhoto?chat_id=00000000&photo=AgAC***rgehrehrhrn
But I don't understand the sendMediaGroup() method. Can someone post an example how to compose the https string to send two photos?
Thanks
You need to send a POST request at the url https://api.telegram.org/botToken/sendPhoto with a JSON body. You are using the url to specify all the parameters of the request but urls are only 2000 characters long. The body of a POST request, instead, has no limits in terms of size. The JSON body should look something like this:
{
"chat_id": 777000,
"media": [
{
"type": "photo",
"media": "https://example.com/first_photo_url.png",
"caption": "an optional description of the first photo",
"parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
},
{
"type": "photo",
"media": "https://example.com/fsecond_photo_url.png",
"caption": "an optional description of the second photo",
"parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
}
],
}
For more info see:
how to send JSON (raw) data with Postman
and
sendMediaGroup Telegram API's method.
You must send JSON as a string, or serialized JSON, to Telegram API. The format is as same as #GioIacca9's answer.
Note: only the caption in the first image will be showen.
Have a try this Python code.
def send_photos(api_key, chat_id, photo_paths):
params = {
'chat_id': chat_id,
'media': [],
}
for path in photo_paths:
params['media'].append({'type': 'photo', 'media': path})
params['media'] = json.dumps(params['media'])
url = f'https://api.telegram.org/bot{api_key}/sendMediaGroup'
return requests.post(url, data=params)
if __name__ == '__main__':
send_photos('your_key', '#yourchannel', ['http://your.image.one', 'http://your.image.two'])

Getting "Bad Request" for Postman API

I simply took an example from Postman API Documentation for Create Collection and removed the extra request outside the folder.
My intention is to create just a folder with 1 request in it.
Here is the request:
{
"collection":{
"variables":[
],
"info":{
"name":"Sample Collection",
"description":"This is just a sample collection.",
"schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item":[
{
"name":"This is a folder",
"description":"",
"item":[
{
"name":"Sample POST Request",
"request":{
"url":"echo.getpostman.com/post",
"method":"POST",
"header":[
{
"key":"Content-Type",
"value":"application/json",
"description":""
}
],
"body":{
"mode":"raw",
"raw": "{
\"data\": \"123\"
}"
},
"description":"This is a sample POST Request"
},
"response":[
]
}
]
}
]
}
}
But for this, I am getting "Bad Request" error, what exactly is wrong with my request?
EDIT - Here's what it looks like in Postman
To me, it looks like you’re trying to send the whole collection json file back to that route.
The JSON in the request body on the image is what you would import into Postman to get the Sample Collection folder. This contains a request called Sample POST Request
Copy the request body JSON and save it as a .json file - Then import this using the Import feature in the top left on the application.
This will then create the folder for you in the application with the sample POST request.
If you send it to the echo URL, you will receive a response telling you that the URL has now changed to https://postman-echo.com/post - Add this new URL into the address bar and hit Send.