Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

"This operation is not supported for a relative URI " Exception when doing batch operation

(0) ShareShare
ReportReport
Posted on by

Our use case is to create an entity and also link the navigation properties present in the entity. To achieve this use case we are making use of batch request with change set where the first request in the set will create the entity and subsequent requests will add the navigation property links to created entity.We are referring the created entity via $1 (Content -Id for first batch request) while creating request urls for adding navigation property links.
Our batch request looks like below:

--batch_B1
Content-Type: multipart/mixed;boundary=changeset_CS1

--changeset_CS1
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-ID: 1

POST {{WebAPIUrl}}/contacts  HTTP/1.1
Content-Type: application/json

{"emailaddress3":"yahoo@gmail.com","lastname":"yahoo"}

--changeset_CS1
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-ID: 2

POST $1/opportunity_parent_contact/$ref  HTTP/1.1
Content-Type: application/json

{"@odata.id":"adobe3.api.crm.dynamics.com/.../opportunities(opportunityid=780e0283-5bf2-e311-945f-6c3be5a8dd64)"}


--changeset_CS1--
--batch_B1--


In this we are creating an contact entity and then adding opportunity_parent_contact navigation property link. But i am getting below exception

{
    "Message": "This operation is not supported for a relative URI.",
    "ExceptionMessage": "This operation is not supported for a relative URI.",
    "ExceptionType": "System.InvalidOperationException",
    "StackTrace": "   at System.Uri.get_AbsoluteUri()\r\n   at Microsoft.Crm.Extensibility.ODataV4.Edm.EdmExtensions.GetNormalizedRequestUri(HttpRequestMessage request)\r\n   at Microsoft.Crm.Extensibility.CrmODataFormatter.GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType)\r\n   at System.Net.Http.Formatting.DefaultContentNegotiator.Negotiate(Type type, HttpRequestMessage request, IEnumerable`1 formatters)\r\n   at System.Web.Http.Results.NegotiatedContentResult`1.Execute(HttpStatusCode statusCode, T content, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable`1 formatters)\r\n   at System.Net.Http.HttpRequestMessageExtensions.CreateResponse[T](HttpRequestMessage request, HttpStatusCode statusCode, T value, HttpConfiguration configuration)\r\n   at System.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(HttpRequestMessage request, HttpStatusCode statusCode, Func`2 errorCreator)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExceptionHandler.CreateHttpErrorResponse(HttpRequestMessage request, Exception exception, HttpStatusCode statusCode, Int32 errorCode)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExceptionHandler.CreateHttpErrorResponse(ExceptionHandlerContext context, HttpStatusCode statusCode, Int32 errorCode)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataExceptionHandler.Handle(ExceptionHandlerContext context)\r\n   at System.Web.Http.ExceptionHandling.ExceptionHandler.HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken)\r\n   at System.Web.Http.ExceptionHandling.ExceptionHandler.System.Web.Http.ExceptionHandling.IExceptionHandler.HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken)\r\n   at System.Web.Http.ExceptionHandling.LastChanceExceptionHandler.HandleAsync(ExceptionHandlerContext context, CancellationToken cancellationToken)\r\n   at System.Web.Http.ExceptionHandling.ExceptionHandlerExtensions.<HandleAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.OData.Batch.ODataBatchRequestItem.<SendMessageAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.OData.Batch.OperationRequestItem.<SendRequestAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataBatchHandler.<ExecuteRequestMessagesAsyncImplementation>d__15.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataBatchHandler.<>c__DisplayClass8_0.<<ExecuteRequestMessagesAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.<ExecuteAsync>d__11`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.<ExecuteAsync>d__6`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataBatchHandler.<ExecuteRequestMessagesAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.OData.Batch.DefaultODataBatchHandler.<ProcessBatchAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Batch.HttpBatchHandler.<SendAsync>d__0.MoveNext()",
    "ErrorCode": "0x0"
}


Can someone please help and let us know the cause of failure. Also any pointers for achieving the use case would be helpful.

Thanks

*This post is locked for comments

  • Keith Digby Profile Picture
    5 on at
    RE: "This operation is not supported for a relative URI " Exception when doing batch operation

    Did you ever manage to resolve this, I have the same issue:

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans