Creating Post with Dynamics CRM Web API - odata

A Post entity (https://msdn.microsoft.com/en-us/library/mt607553.aspx) cannot be created using Dynamics CRM 2016 Online Web API.
This payload should create a post on POST /api/data/v8.1/posts
{
"text": "Test Single Post",
"source": 1,
"type": 7
}
(source 1 is an auto post, type 7 is a status post)
But it returns:
{
"error":
{
"code":"",
"message":"An unexpected error occurred.",
"innererror"
{
"message":"An unexpected error occurred..."
}
}
}
Submitting the same payload with only "text" fails too.
Notice that the Post entity does not have single-valued navigation properties (https://msdn.microsoft.com/en-us/library/mt607553.aspx#bkmk_SingleValuedNavigationProperties) that will allow me to set the related entity (contact, account, etc).
For example, Creating a Task entity (https://msdn.microsoft.com/en-us/library/mt607619.aspx) works fine on POST /api/data/v8.1/tasks
{
"subject": "Test Single Task",
"description": "Test One Description of Task",
"regardingobjectid_contact_task#odata.bind": "/contacts(<someguid>)",
"scheduledend": "2016-07-21T12:11:19.4875892Z"
}
It seems to me that Post should expose something like regardingobjectid_contact_post#odata.bind, but it does not.
For context, this is how to create a Post via the SOAP endpoint and the SDK:
var result = Client.getOrganizationService().Create(new Post
{
Text = post.text,
RegardingObjectId = new EntityReference(
entityName,
Guid.Parse(post.regarding_guid)
)
});
Does anyone have a working example of a Post created via the Web API? Is this an omission in the Dynamics CRM Web API?
It doesn't look like this is listed in the limitations: https://msdn.microsoft.com/en-us/library/mt628816.aspx
UPDATE
It appears that the postregarding entity is where the link should be created to contact/account. This can be demonstrated by querying:
/posts?$filter=postregardingid/regardingobjectid_contact/contactid eq <someguid>
However, a "deep insert" like so does not work:
{
"text":"sometext",
"postregardingid":
{
"regardingobjectid_contact#odata.bind":"/contacts(someguid)"
}
}
The response is
Cannot create child entities before parent entity.

Nowhere it's mentioned like Post (activity feed) cannot be created using webapi. In fact it's not listed as crm webapi limitation like you pointed out.
Also on comparison, _regardingobjectid_value lookup property of post is different from activitypointer. Single valued navigation property too.
Out of curiosity, My investigation moved towards the Partner - post_PostRegardings
Only thing making sense - postregarding is strictly internal use. This could be the reason for all such behavior. This is my theory per v8.2 today(Aug 12 2017)
Description: Represents which object an activity feed post is regarding. For internal use only.
Entity Set path:[organization URI]/api/data/v8.2/postregardings
Base Type: crmbaseentity EntityType
Display Name: Post Regarding
Primary Key: postregardingid
Ref: https://msdn.microsoft.com/en-us/library/mt608103.aspx
Update:
Looks like MS recommend the community to use Organization service to create a custom Post record. Web api is still broken. Read more

I was recently struggling with this issue with an Activity table made using powerapps. For those who are interested, here's my post request:
POST: https://<MY_DOMAIN>.crm.dynamics.com/api/data/v9.1/<TABLE_NAME>
{
"regardingobjectid_contact#odata.bind": "/contacts(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)",
"description": "data for this entity",
"subject": "more data"
}
I didn't do anything different from other peoples' answers. I'll give an update if this problem fails sporadically. But as it is right now, it looks like regardingobjectid may be working in version 9.1

using D365 Api v9.1
POST https://{domain}.crm4.dynamics.com/api/data/v9.1/posts
{
"regardingobjectid_contact#odata.bind":"/contacts(guid)",
"text": "This is a private message post",
"source": 1,
"type": 4
}
source :
Auto Post
Manual Post
ActionHub Post
type :
Check-in
Idea
News
Private Message
Question
Re-Post
Status

Related

Making a simple authorized request to eBay

I'm planning to integrate a website with eBay using PHP, but first I'm using Postman to test everything.
Authorization took me an entire day, but I think I've got it working now. (I had to update to the latest version of Postman, then I got it to create a token for me.)
I say I think because I haven't managed to get a single request to work. I deliberately chose bulkGetInventoryItem (documentation) as it seemed like one of the easier authorized requests to get working. I just know that when the authentication settings are wrong, I get a different error message to when they are right.
For troubleshooting reasons, I made a token with all the scopes:
https://api.ebay.com/oauth/api_scope
https://api.ebay.com/oauth/api_scope/sell.marketing
https://api.ebay.com/oauth/api_scope/sell.inventory
https://api.ebay.com/oauth/api_scope/sell.account
https://api.ebay.com/oauth/api_scope/sell.fulfillment
https://api.ebay.com/oauth/api_scope/sell.finances
https://api.ebay.com/oauth/api_scope/sell.payment.dispute
https://api.ebay.com/oauth/api_scope/commerce.identity.readonly
(added as space-separated list of links)
I have changed one of the eBay listings to have an SKU of "123456" just for this test, however the error I get is exactly the same as if I change "sku": "123456" to "sku": "anObviouslyFakeSKU", but anything else I change creates a new error, so I'm suspecting the issue to be SKU related, but maybe it isn't. (I've found the eBay API to be very poor at sending relevant error messages.)
I'm quite new to Postman, so it's likely a rookie mistake.
Earlier errors have shown to be minor punctuation issues or wrong radio buttons ticked, so hopefully whatever the error is this time, it should appear in this screenshot.
What did I do wrong this time? (Let me know if there are any other screenshots I can send that might help.)
To help, both with the post's SEO, and ease of copy/pasting, I am transcribing the important text in the screenshot above:
url
POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item
body, raw
{
"requests": [
{
"sku": "123456"
}
]
}
output
{
"errors": [
{
"errorId": 2003,
"domain": "ACCESS",
"category": "APPLICATION",
"message": "Internal error",
"longMessage": "There was a problem with an eBay internal system or process. Contact eBay developer support for assistance",
"parameters": [
{
"name": "reason",
"value": "Failed to transform underlying error response, see logs."
}
]
}
]
}
Update:
One more screenshot
Update 2:
Another screenshot
A few things you need to check for in Postman.
When you authenticate and receive a token are you posting that token with your api calls like this one POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item?
Have you set the Authorization HTTP header for authentication authorization?
Have you set the Content-Type header for the call to application/json?
More info here: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/bulkGetInventoryItem
Update
Authorization with environment variable in Postman:
Postman environment variables documentation:
https://learning.postman.com/docs/postman/variables-and-environments/variables/
I figured out the issue. My biggest mistake was choosing bulkGetInventoryItem as the "simplest" call. I should have chosen getInventoryItem, as the error reporting on that function is far more user friendly.
So the error I got, for exactly the same request was "We didn't find the entity you are requesting. Please verify the request"
A quick google of the error found me this page https://forums.developer.ebay.com/questions/17883/cannot-get-my-listed-product-by-get-inventory-api.html which led me to the correct answer!
The inventory item I was trying to access was unreachable because it was not created through the developer API.
I hope this answer helps others, as it wasted a full day of my life trying getInventoryItem before tackling bulkGetInventoryItem.

How do I get a usable email message reference id from headers to use in a Microsoft Graph query?

I am trying to use the references message ID in email headers of a forwarded email in Office 365 to then find the original email that has that message ID.
The references ID in the forwarded email's headers would show something like what's shown below. Note I'm obtaining these headers from Microsoft Graph by adding &$select=internetMessageHeaders to my query using sender/subject to find the forwarded email.
{
"name": "References",
"value": "<CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w#mail.gmail.com>"
}
However, if I take this and use it in a query like https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w#mail.gmail.com>'
I do not receive any results.
If I hunt down the original email in Microsoft Graph using sender and subject, I see the following for the internetMessageId field for the original email:
{
"name": "Message-ID",
"value": "<CAOLK2SC6s9Me05kYRqeuEHKK8DrQbXx34ScT0AzGOFFLMdRapg#mail.gmail.com>"
}
Does anyone have any ideas on what Office 365 or Microsoft Graph is doing to change CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w into CAOLK2SC6s9Me05kYRqeuEHKK8DrQbXx34ScT0AzGOFFLMdRapg? It looks like some sort of encoding, but I haven't been able to reproduce it.
Ultimately I would like to be able to transform what I'm getting in the references ID header such that I can turn around and use that ID to find the original email using Microsoft Graph.
The id is a hashed value that, among other things, includes the path/folder that the message resides in. So if you, for example, move a message (say from Inbox to Archive) then you should expect the id to change.
For tracking a message, regardless of its location, you should use the internetMessageId ($select=internetMessageId) property instead.
I discovered the issue. In my test message-ID I have the characters = and +
These characters must be URL encoded to %3D and %2B before being used in the $filter query. When they are URL encoded, I am able to find the original email using MS Graph.
In Microsoft Graph v1.0 and beta, you can obtain "immutable ids" by sending an additional HTTP header in your API requests:
Prefer: IdType="ImmutableId"
I've put immutable in italics as this is the term Microsoft uses. Be aware of the following caveats, the ID will change if:
The user moves the item to an archive mailbox;
The user exports the item (to a PST, as an MSG file, etc.) and re-imports it into their mailbox;
The user creates a draft which they later send;
You can also convert existing ids to immutable ones by the following request:
POST https://graph.microsoft.com/beta/me/translateExchangeIds
{
"inputIds" :
[
"AQMkAGM2…"
],
"targetIdType" : "restImmutableEntryId",
"sourceIdType" : "restId"
}
Which will give you the response:
HTTP 200 OK
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.convertIdResult)",
"value": [
{
"targetId": "AAkALgAA...",
"sourceId": "AQMkAGM2..."
}
]
}

You should specify a parent contact or account error in Dynamics CRM

I am trying to create a new incident through postman in Dynamics CRM but I am getting the following error:
You should specify a parent contact or account
Which I assumed that is asking for customerid to be sent so I added it on postman like:
{
"description": "Test",
"ed_egresssenttorentadmin": true,
"note['_customerid_value#odata.bind']":"f686f062-e542-e811-a955-000d3ab27a43",
"note['_ownerid_value#odata.bind']":"a7b7fcb7-a64e-e811-a96f-000d3ab384bc"
}
but I still get the same error, any idea on how to set accountId when creating a new incident ?
According to RESTBuilder it should look something like this.
entity["customerid_account#odata.bind"] = "/accounts(f686f062-e542-e811-a955-000d3ab27a43)"
Actually this is the basic payload needed to create an incident:
{
"title": "case test",
"customerid_account#odata.bind": "/accounts(f686f062-e542-e811-a955-000d3ab27a43)"
}

Survey Monkey API Questions

I have a couple questions regarding the survey monkey API. First, I've noticed that the categories that can be assigned to open ended questions don't come through when pulling the details of a response. Is there a way to do this and if not, when will it be added?
Secondly, I've attempting to update the metadata field of a response, yet I'm receiving an invalid schema era.
I'm sending this in the request body:
{
"id": "4472927205",
"metadata": { "category" : "test"
}
}
This is the response I receive:
{
"error": {
"http_status_code": 400,
"message": "Invalid schema in the body provided.",
"id": "1002",
"docs": "https://developer.surveymonkey.com/api/v3/#error-codes",
"name": "Bad Request"
}
}
What is the proper schema for a request?
Categories set in the analyze section are not currently accessible through the API. There is no ETA for that at the moment.
Also the metadata shown in the responses are auto-generated based on other factors (some page logic I believe, contact information - case email collector) and are not updateable at the moment either.
See the docs also you can watch the public docs repo to be notified when the changes you'd like have been released.

Get Recommendation from LinkedIn API returns empty map [:] as response

I have created a web application from which I am trying to get recommendations of a user from his/her LinkedIn Profile using URL
String url="https://api.linkedin.com/v1/people/~:(recommendations-received:(id,recommendation-type,recommendation-text,recommender))?format=json"
When I am using this URL in the
Api Explorer it works fine. And gives output:-
{ "recommendationsReceived": {
"_total": 2,
"values": [
{
"id": 558598601,
"recommendationText": "xxx is among the best team players I ever worked with. He has handled client effectively with smooth operations. I had always seen him as person with solution mindset and always look for solution rather than thinking about the problem. ",
"recommendationType": {
"code": "colleague"
},
"recommender": {
"firstName": "XXX",
"id": "YYYY",
"lastName": "XXX"
}
},
{
"id": ZZZZ,
"recommendationText": "XXX is one of the most dedicated person at work.I always him with a flexible attitude and ready to adapt himself in all situation.I have seen him work all night to catch up all the deadlines and deliver on time ."
"recommendationType": {
"code": "colleague"
},
"recommender": {
"firstName": "XXX",
"id": "YYYY",
"lastName": "XXXX"
}
}
] } }
The problem comes, when I am using this URL in my Developer app.It doesn't give any error just simple return an empty map [:] as output in response
Irrespective of these recommendation fields, I successfully get the user basic profile data such as email, id, image,firstName,lastName.Means my code is working for other fields well but not for these recommendation fields*
To find the solution, I did some internet surfing and find a link of Linked API docs
Linked API Docs
As per Docs following selection of profile fields are only available
to applications that have applied and been approved for the Apply with
LinkedIn program:
Recommendation Fields
I already created a LinkedIn Developer account to get key & Secret
So how do I apply and get approval for Apply with LinkedIn Recommendation Fields.
I already have seen the LinkedIn support but can't find the way to ask question to the Linked Developer help support
Please suggest me the right way.
After a long internet surfing,I have found something fruitful that, I have to fill up a form to get these fields.Here is the form
along with its procedural details
You can use just recommendations-received keyword. Try the following link. I am getting all recommendations details with this link.
https://api.linkedin.com/v1/people/~:(recommendations-received)?format=json

Resources