web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Web API Batch Transactions - Content-ID URI Variables Not Working

(0) ShareShare
ReportReport
Posted on by 5

My team is having some trouble using changeset variables in batch transactions, as described in the official MSDN documentation for Dynamics 365 Web API Batch requests. When we attempt to reference an entity that was created in a previous changeset request with a "Content-ID: 1" header and use $1 as the root of the next changeset request's target URI, it returns an error stating “Invalid URI: The format of the URI could not be determined.” Here is an example of such a request:

--batch_1

Content-Type: multipart/mixed; boundary=changeset_2

 

--changeset_2

Content-Type: application/http

Content-Transfer-Encoding: binary

Content-ID: 1

 

POST /api/data/v8.2/contacts HTTP/1.1

Content-Type: application/json

Prefer: return=representation

 

{

    "firstname": "TestFirst1",

    "lastname": "TestLast1",

    "emailaddress1": "str@ing.com",

    "gendercode": 1 

}

 

--changeset_2

Content-Type: application/http

Content-Transfer-Encoding: binary

Content-ID: 2

 

POST $1/lastname HTTP/1.1

Content-Type: application/json

Prefer: return=representation

 

{

    "value": "TestLast2"

}

--changeset_2--

 

--batch_1--

I haven't encountered anything online indicating that the format of the reference URI is incorrect, and the request works fine when it is hardcoded as "POST api/data/v8.2/contacts(<entity guid>)/lastname HTTP/1.1"

Strangely enough, I haven't encountered any examples online of anyone using this feature against CRM. Is it supported, or is the MSDN documentation incorrect?

*This post is locked for comments

I have the same question (0)
  • Sub Profile Picture
    27 on at

    This is quite an old post but I have run into a similar issue with batch requests.

    It fails when using Content-ID's along with Prefer: return=representation with the message:

    Content-ID Reference: '$1' does not exist in the batch context

    It works perfectly if I remove Prefer: return=representation - however I need this to get ID/lookup fields back.

    I haven't been able to find any documentation regarding the two.

    Does anyone know of a solution?

    EG

    --dwa_batch_86262503-77f0-41f6-8a69-3412c4c73e1f

    Content-Type: multipart/mixed;boundary=changeset_6b0e18cc-bae8-4365-8348-1d4cc2dcc068

    --changeset_6b0e18cc-bae8-4365-8348-1d4cc2dcc068

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    Content-ID: 1

    PATCH https://.dynamics.com/api/data/v9.2/entity1 HTTP/1.1

    Content-Type: application/json

    Prefer: return=representation

    {"data" : "here"}

    --changeset_6b0e18cc-bae8-4365-8348-1d4cc2dcc068

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    Content-ID: 100001

    PATCH https://.dynamics.com/api/data/v9.2/entity2 HTTP/1.1

    Content-Type: application/json

    {"data" : "here"}

    --changeset_6b0e18cc-bae8-4365-8348-1d4cc2dcc068--

    --dwa_batch_86262503-77f0-41f6-8a69-3412c4c73e1f--

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans