How can I make a POST request to my Dynamics CRM from Postman? - dynamics-crm

I am having trouble making a successful HTTPS Post Request to my Dynamics Health 365 CRM.
My goal is to update the "description" field for one specific contact through a Post request.
I am able to make a successful Get request for this specific contact by passing in their contactid to the /contacts path.
get req
However, I am unable to make a Post request on this URI for my CRM site. I am consistently met with a "405 - Method Not Allowed" response.
post req body
Here are the headers I have set. Is there something I am not doing correctly to add content to a certain field for a certain contact?
post req headers
I have also tried to use a Put request but am met with the same 405 error.
I do not know of any guidance on the Dynamics CRM Web API documentation. If there is any content specifically on making Post requests to the Dynamics CRM, I would be more than happy to look to that. I am just looking for any guidance on this because I feel like I have totally hit a wall on this for the last few days. Anything helps, thank you!!
This is for a dynamics CRM portal
I am able to make Get requests on this same URL
I think I need to set the key-value pair of the data I want to update in the body of the request, but that seems not to be correct. Either that, or I am not doing some preliminary step in order to allow for that Post body content to be applied to the contact I am passing.
I want the "description" field in the contact's data to update to the value I set it to. See second image of my post request body.

I recommend you to check the documentation, it has a Postman specific section and some helpful examples.
About your question, updates use the HTTP PATCH verb (POST is used for create operations):
PATCH [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001) HTTP/1.1
Content-Type: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"name": "Updated Sample Account ",
"description": "This is the updated description of the sample account"
}
If you're trying to update a single attribute, you can use PUT as you did but the URL must include the attribute name (/name after the record id in this case):
PUT [Organization URI]/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001)/name HTTP/1.1
Content-Type: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{"value": "Updated Sample Account Name"}
More about update operations on the documentation.
You can also check out the Postman collection template I created some time ago in GitHub.

Related

how to get the value of "CrmOwinAuth" in ms dynamics?

I was making a request through my browser console to my MS Dynamics instance to retrieve some information. I downloaded the network request made and converted it into a curl request. Then, imported that curl request into postman and made a GET request. I got the same results in both cases. But, in the request, there is a parameter called "CrmOwinAuth".
I want to get the value of this parameter. I made another POST request to get my access token of MS Dynamics and compared the value of it with this "CrmOwinAuth" but, they were different.
Can anyone please tell me how can I get the value of this CrmOwinAuth? I need this value to make my curl request for some other user and retrieve its information from ms dynamics.

Handling text/plain request in Laravel (sent via navigator.sendBeacon)

Problem:
I am trying to get the content / body from a text/plain POST request in a Controller in Laravel 8.
Nothing in the docs or numerous google searches worked.
I have tried:
$request->input();
$request->all();
$request->json();
json_encode($request);
All of these seem to show that the request is completely empty.
Context
This may not be relevant to the solution, but might help other's who are trying to google this problem: The request I am trying to handle with my controller is being sent by navigator.sendBeacon on the client side. The request body is actually stringified JSON, but sendBeacon does not allow you to send requests with content-type JSON. Devtools show the content-type header for this request as 'text/plain'.
My Answer:
Use $request->getContent() to get the content of a text/plain HTTP request.
And then, if you are in a situation like mine where the text is actually JSON, use json_decode($request->getContent(),true) to get a standard PHP array from the content which you can use in your Controller.
It turned out to be quite simple, but the information was not in the docs, or in any online searches so I thought it would be worthwhile to post to SO anyways...
You can send the data as JSON like this instead
data = new Blob([JSON.stringify(data)], {type : 'application/json'})
navigator.sendBeacon('/your/route/here', data)

How to Create Elasticsearch Point in Time (PIT)?

I'm trying to use the search_after parameter with a point in time (PIT) to paginate search results. This is the documentation section I'm consulting.
I'm making a POST to /my-index/_pit?keep_alive=1m.
The /_pit endpoint only accepts the POST method (if I try GET, it says only POST is accepted), and per the doc, does not take a request body. However, the response I receive is a 400 with this message:
"type": "parse_exception",
"reason": "request body is required"
I can't find any other examples of a /_pit request and I'm just confused by these responses.
Has anyone successfully gotten back a PIT?
In case it's relevant, we have a managed elastic cloud deployment on a standard subscription.
I ended up finding an Elastic forum post indicating that the PIT API is only available as of version 7.10. Sure enough, I tried against a 7.10 deployment and it succeeded as a POST without a body.
So, I feel as though there isn't much guidance on this outside of this particular example and I felt the need to post this for other users that struggled as I did.
If you're using an API tool like postman, you have to update your headers to include Content_Type: application/json, and set your authorization method as what you need (I used basic for password and username).
The index that you should use (my-index-000001 from their example) should be one that you've set up for your search query (right before the _search portion). Leave the body empty and send over the post request and you'll get your id.

Google Calendar Event Insert HTTP message format?

Google provides the HTTP message format for all the Oauth messages but nothing when it comes to the Calendar's API.
I suspect they want you to use one of their libraries -- but I don't use any of the languages associated with their libraries.
I'm using C++ and forming my own HTTP headers and message content.
Can anyone provide a standard HTTP format for Calendar-event-insert?
I know it must be in JSON construction.
The data I want to send is:
Calendar ID will be "primary"
Summary
Description
Start time
End Time
Based on oauth messages - I'm assuming the message may also have to contain:
ClientID
AccessToken
Scope
redirect_uri
I am looking for correct "Key" strings(case sensitive) and format.
Thanks in advance for any help.
You can do this all your self. The doucmentation is all there
Calendar event.insert
If all you want to do is see the HTTP request that is made by the api you can use If you use the event.Insert try me You can see the request it builds and test that its working
POST https://www.googleapis.com/calendar/v3/calendars/primary/events HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
Content-Type: application/json
{
"end": {
"date": "2020-01-01"
},
"start": {
"date": "2020-01-01"
},
"description": "test",
"summary": "test"
}
With a post body of events.resource
oauth
If you have your own C++ oauth library you can probably use that to get an access token. Once you have the access token you simply need to add a Authorization header to the post request above with a bearer token of the access token.
Sorry i cant help much with the code for c++ but i made my own library for .net 3.5 because it was not supported by googles .net client library, so i can tell you that its doable you just have to do it all yourself.
Google c++ library
There is a c++ library its just deprecated but that doesn't mean you cant dig around in their code for a bit of help in doing this Google apis cpp client

TrustPilot Create Invitation API always returns 415 response code

I'm trying to send a TrustPilot invitation using the Create Invitations API but no matter what I try, I get a response code of 415 and with no data returned, so it's virtually impossible for me to debug.
The URL I'm using is correct: https://invitations-api.trustpilot.com/v1/private/business-units/{businessUnitId}/email-invitations (where {businessUnitId} is my business ID)
I am sending a valid (and current) oAuth token in my header.
I am sending a POST request.
I have tested my details with other "Business user OAuth Token" APIs and everything works, so my details are definitely correct. It's just this create invitation API that's not working.
I've tried everything. I've submitted minimal details, a full request, somewhere in between, the example request in the API, and so on. Always a response code of 415.
I've set my "Invitation Settings" in the TrustPilot Business portal, and have even tried submitting those details with the request (ie. sender e-mail "noreply.invitations#trustpilotmail.com" and a valid reply-to e-mail that's been configured).
I've tried contacting the "Integration Engineers" at TrustPilot who after a few back and forth e-mails, also have no idea, which is VERY unsettling. So time for Stack Overflow.
I need to get this figured out, so any help would be great! Perhaps someone can provide a sample request that works in their application that I can try to duplicate in mine?
Http status code 415 (Unsupported Media Type) is returned when Content-Type: application/json is not passed. You need to make sure that this header is added and that the content you are passing in the post body is valid json.
If you are already doing this then I would need an example of a request you are sending to help you further.

Resources