Hi,
I'm new at using the API, but I have been able to read data from the API and also post a Task via the API!
However now I want to submit a Post to a specific account via the API! But I get an Error: error BAD request!
Any ides why this is!
This is the code I use:
var entity = {}; entity["regardingobjectid_account@odata.bind"] = "/accounts(22FAECC2-43C8-E611-8102-C4346BAC4B68)"; entity.source = 3; entity.text = "API Post Test"; entity.type = 3; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", datatype: "json", url: Xrm.Page.context.getClientUrl() + "/api/data/v8.2/posts", data: JSON.stringify(entity), beforeSend: function(XMLHttpRequest) { XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0"); XMLHttpRequest.setRequestHeader("OData-Version", "4.0"); XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, async: true, success: function(data, textStatus, xhr) { var uri = xhr.getResponseHeader("OData-EntityId"); var regExp = /\(([^)]+)\)/; var matches = regExp.exec(uri); var newEntityId = matches[1]; }, error: function(xhr, textStatus, errorThrown) { Xrm.Utility.alertDialog(textStatus + " " + errorThrown); } });
I'm a bit unsure on what the put on the source and type entity??
thanks for any help
//Martin
*This post is locked for comments