Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Web API - Set lookup field using alternate key

$
0
0

Hi

I am trying to create a contact record using web api. I have a customer lookup field called parent account on the contact entity. I want to specify this field in web api using the alternate key (have define emailaddress1 as alternate key on account). I am using the following code but getting error that parent account field is not defined. Any ideas?

function createOperationUsingWebAPI() {

var clientUrl = Xrm.Page.context.getClientUrl();

var req = new XMLHttpRequest()

req.open("POST", encodeURI(clientUrl + "/api/data/v8.0/contacts"), true);

req.setRequestHeader("Accept", "application/json");

req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

req.setRequestHeader("OData-MaxVersion", "4.0");

req.setRequestHeader("OData-Version", "4.0");

req.onreadystatechange = function () {

var accountUri = this.getResponseHeader("OData-EntityId");

};

var body = JSON.stringify({

"firstname": "Test",

"lastname": "WEB API",

"new_parentaccount@odata.bind":"/accounts(emailaddress1='someone_i@example.com')"

});

req.send(body);

}

Thanks


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>