The Dynamics CRM2016 Web API Gets the text of the lookup field and the text of the option set

Source: Internet
Author: User

This article again to introduce the function of the Web API, about the text of the lookup is only slightly, because there is expand, the existing Web API can be implemented, mainly refers to the text of the option set, we find through the Basic Query API field value only with value, If you want to get text is also very simple, just need to add a message to the head of the request, the following is the C # and JS sample code.

HttpWebRequest req = (HttpWebRequest) httpwebrequest.create (Weburi);            Req. Credentials = new NetworkCredential (username, pwd, domain);            Req. Method = "Get";            Req. Accept = "Application/json";            Req. ContentType = "Application/json; Charset=utf-8 ";            Req. Headers.set ("Odata-maxversion", "4.0");            Req. Headers.set ("Odata-version", "4.0");            Req. Headers.set ("Prefer", "Odata.include-annotations=odata.community.display.v1.formattedvalue");            using (HttpWebResponse res = (HttpWebResponse) req. GetResponse ())            {                StreamReader read = new StreamReader (res. GetResponseStream ());                result = read. ReadToEnd ();            }

var req = new XMLHttpRequest ()    req.open ("get", url);    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.setrequestheader ("Prefer", "Odata.include-annotations=odata.community.display.v1.formattedvalue");    Req.onreadystatechange = function () {        if (this.readystate = = 4) {            if (this.status = =) {                Successcallback (J Son.parse (This.responsetext));            }            else {                errorcallback (Json.parse (this.responsetext). error.message);}}}    ;    Req.send ();

As you can see from the following, the text value has been queried.


Dynamics CRM2016 Web API Gets the text of the lookup field and the text of the option set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.