Ride Reminders Uber Api got JSON error - uber-api

Hello I am trying implement Ride Reminder Uber API in my project but I got error response like:
Reference URL:
https://developer.uber.com/docs/v1-reminders-post
JSON Error Response:
{
"message": "Unable to parse JSON in request body.",
"code": "invalid_json"
}
URL
https://api.uber.com/v1/reminders
Headers:
Content-Type: application/json
Authorization: Token vzOv0AaaZVRaV1FiZLt9SPU2ZgIrBgQ6uZy6j4Gr
Post Params:
reminder_time:1451496600(Unix UTC timestamp of when the reminder will occur.)
phone_number: +91xxxxxxxxxx(India's number)
server_token: vzOv0AaaZVRaV1FiZLt9SPU2ZgIrBgQ6uZy6j4Gr
event: {
"time": "1451498400",
"longitude": "72.5290",
"latitude": "23.0384",
"location": "Vastrapurlake",
"name": "Test"
}
More detail check PostMan Screen shots:
Post Params:Click here
Header Params:Click here
Can you please help me out, Thanks In Advance!!

Your Content-Type and token are valid dont change anything there.
Just convert your params in json dont forgot to use double quote.
You have to pass these data as json format in postman.
{"reminder_time":"1451649600",
"phone_number": "+91<YOUR-MOBILE-NUMBER>",
"server_token": "vzOv0AaaZVRaV1FiZLt9SPU2ZgIrBgQ6uZy6j4Gr",
"event": {
"time": "1451649600",
"longitude": "72.5290",
"latitude": "23.0384",
"location": "Vastrapurlake",
"name": "Test"
}}

Related

How do I use Marketo REST API with Postman?

I'm having a hard time trying to figure out how to properly use the Marketo REST API using Postman for testing purpose.
So far I can Authenticate and get my access_token,
but when I try to create a folder... (properly authenticated)
endpoint: [POST] /rest/asset/v1/folders.json
body:
{
"description": "Test Folder",
"name": "Test",
"parent": {
"id": 1,
"type": "Folder"
}
}
I get:
{
"success": false,
"errors": [
{
"message": "name cannot be null.",
"code": "701"
},
{
"message": "parent cannot be null",
"code": "701"
}
],
"requestId": "408a#1720c00a893",
"warnings": []
}
I don't know what I'm doing wrong.
See an example in the Marketo API documentation
Create/Update folder request should be an application/x-www-form-urlencoded not application/json
So in Postman, you have to post a form with three parameters:
parent={"id":416,"type":"Folder"}
name=Test 10 - deverly
description=This is a test
For the parent parameter you should specify a specific json-like text, which is a usual format for folderId
For generic folders (not programs) you can provide just integer id, without JSON structure, this is not recommended but can be used for manual API tests

Http response code for a mixed type of response payload containing both error and success messages

I am developing an API which accepts requests for multiple image uploads in the following format:
{
"images"[
{"url": 'www.xyz/image1.jpg', 'type': 'abc'},
{"url": 'www.xyz/image2.jpg', 'type': 'def'}
]
}
The response contains success and failure messages for each image:
{
"error": {
abc": "Error while downloading image: servname or nodename not known"
},
"success": {
"def": "image got uploaded successfully"
}
}
Now I am wondering what status code should I return for this response given the possibility that the response can contain only success, only errors or a mix of success and error messages. Should there be a generic status code for this or depending whether the response contains only errors, success or both, the status codes should be different?
Consider a [207 Multi-Status Response][1], defined in the WebDAV RFC.
A Multi-Status response conveys information about multiple resources
in situations where multiple status codes might be appropriate. The
default Multi-Status response body is a text/xml or application/xml
HTTP entity with a 'multistatus' root element. Further elements
contain 200, 300, 400, and 500 series status codes generated during
the method invocation. 100 series status codes SHOULD NOT be recorded
in a 'response' XML element.
You can return a HTTP response 200 and have the response body contain the further details.
Also you should have a way of mapping the requests to the responses so that you know which success/error message is corresponding to which request.
You can send the request as:
{
"images" : [
{"key": "1", "url": 'www.xyz/image1.jpg', 'type': 'abc'},
{"key": "2", "url": 'www.xyz/image2.jpg', 'type': 'def'},
{"key": "3", "url": 'www.xyz/image3.jpg', 'type': 'abc'}
]
}
And the response as 200 OK with response body:
{
"images" : [
{"key": "1", "status": "success", "message": "OK"},
{"key": "2", "status": "failure", "message": "some specific error"},
{"key": "3", "status": "failure", "message": "some specific error"}
]
}

Custom_args not working in sendgrid V3 API but unique_args sends email but not in event_callback

I have used sendgrid v3 api for sending emails. As mentioned in documentation of V3 API I use custom_args to get my params in event callback but it shows 400 bad request, while I use unique_args, the email was sent but the event callback does not send my unique_args params.
data = {"content": [{"value": "dfafds", "type": "text/plain"}], "attachments": [{"content": "UEsDBB......QACAgIAAA=", "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "content_id": "BqzZqz7LaqO9", "filename": "Contactmanager-company.xlsx", "disposition": "attachment"}], "from": {"email": "bishnusyangja#gmail.com"}, "personalizations": [{"to": [{"email": "bishnu#janakitech.com"}], "custom_args": {"email_msg_id": 106}, "subject": "daff"}]}
Event callback response from send grid is
[{"sg_event_id": "aoDNXRAeRuaCAVRiutD-fg",
"sg_message_id": "epJqlw1JThGw--dDTC1oCQ.filter0099p3las1-8681-5B853F95-29.0",
"smtp-id": "epJqlw1JThGw--dDTC1oCQ#ismtpd0006p1maa1.sendgrid.net",
"timestamp": 1535459222,
"email": "bishnu#janakitech.com",
"event": "processed"}]
I need may custom_args in event callback reponse, In this response I need email_msg_id What is missing here ?
In custom_args, data_type must be string. I fixed it using string data as
"custom_args": {'email_msg_id': '106'}.
While sending mail through java we need to send a unique id from my
side so that when webhook sends me the response I need to check the
status of that mail by its unique id. here is my code in java...
MimeMessage message = (MimeMessage) getNewMessageInstance();
message.addHeader("unique_args", jsonRandomEmailStatisticsId);
And value of jsonRandomEmailStatisticsId is like
{"unique_args":{"randomMessageId":"randomMessageId-308099455"}}
here I got a webhook response from SendGrid
[{
"category": [],
"email": "email#example.com",
"event": "processed",
"marketing_campaign_id": 12345,
"marketing_campaign_name": "campaign name",
"post_type": "event",
"sg_event_id": "sendgrid_internal_event_id",
"sg_message_id": "sendgrid_internal_message_id",
"sg_user_id": 12345,
"smtp-id": "",
"timestamp": 1442349428
}]
But SendGrid does not return random message id values in return of
object response

unable to get my emails via graph API

I'm using the graph api to fetch my emails. and I'm using a postman client, I'm getting the authorize token and sending it to the api as header.
When I run the below query.
https://graph.microsoft.com/v1.0/me
the response that I get is
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "someId",
"businessPhones": [],
"displayName": "MyName",
"givenName": "MyFirstName",
"jobTitle": "MyDesignation",
"mail": "myEmailAddress",
"mobilePhone": "MyMobileNumber",
"officeLocation": "MyWorkLocation",
"preferredLanguage": null,
"surname": "MySurName",
"userPrincipalName": "MyEmailAddress"
}
and when I try to run the below query.
https://graph.microsoft.com/v1.0/me/messages
The response that I get is as below.
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "59a0a25b-67c4-4fe8-8aff-eb035b974a4b",
"date": "2017-03-10T14:09:13"
}
}
}
Also tried the below URL to get the emails.
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages
I get the same response as above.
Finally I tried
https://graph.microsoft.com/v1.0/me/mail
Here the response that I got is
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('someRandomId')/mail",
"value": "myEmailAddress"
}
please let me know how can I get my emails shown.
In the portal(https://apps.dev.microsoft.com), I've the below things enabled for this application.
Thanks

Discover SoundCloud user name

I have a SoundCloud client_id that I would like to know the user_id or user name. Actually I have a full link to a track. Is there anyway I can do it?
I think what you're asking is with a track link, find the user_id and username of the uploader of a track.
If you know the full soundcloud.com track URL, hit the /resolve endpoint. For reference, I will be using this URL: https://soundcloud.com/madanofficial/the-police-walking-on-the-moon-j-art-madan-remix
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmadanofficial%2Fthe-police-walking-on-the-moon-j-art-madan-remix&client_id=[YOUR client_id]
The resulting JSON:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/147986343.json?client_id=[YOUR client_id]"
}
When we hit the SoundCloud API again with the /tracks endpoint, just parse the user object that is returned.
"user": {
"id": 44553705,
"kind": "user",
"permalink": "madanofficial",
"username": "Madan.",
"uri": "https://api.soundcloud.com/users/44553705",
"permalink_url": "http://soundcloud.com/madanofficial",
"avatar_url": "https://i1.sndcdn.com/avatars-000098677604-mwg7te-large.jpg?e76cf77"
}