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 :
Finance | Project Operations, Human Resources, ...
Answered

HTTP resources: Send OData Requests

(3) ShareShare
ReportReport
Posted on by 97
Hello everyone,
I am writing some code with the aim of reading data via the OData service of D365 FO. In the past I have already gained some experience with the mentioned features. For example, I read the metadata and get the relevant information about the available DataEntities.
Normally I can read data from the DataEnties by constructing the request accordingly. I am now attaching an example that already works:

GET {{d365_url}}/data/EngineeringChangeOrderHeaders(OrderNumber='0001',dataAreaId='demf')?cross-company=true
 
Extract from the metadata:
 
<EntityType Name="EngineeringChangeOrderHeader">
    <Key>
        <PropertyRef Name="dataAreaId" />
        <PropertyRef Name="OrderNumber" />
    </Key>
    ...
</EntityType>
 
As you can see, the corresponding URL is filled with the keys of the EntityType. This works for the majority of entities. However, this error is always returned for the entity I want to read (ProductDocumentAttachment):
"No HTTP resource was found that matches the request URI '{{d365_url}}/data/ProductDocumentAttachments(ProductNumber='000666',DocumentAttachmentTypeCode='URL',AttachmentDescription='URL20240709-091930',AttachedDateTime='2024-07-09T07:19:31')'. No route data was found for this request."
 
The corresponding metadata entry shows the keys to be used:
 
<EntityType Name="ProductDocumentAttachment">
    <Key>
        <PropertyRef Name="ProductNumber" />
        <PropertyRef Name="DocumentAttachmentTypeCode" />
        <PropertyRef Name="AttachmentDescription" />
        <PropertyRef Name="AttachedDateTime" />
    </Key>
    ...
</EntityType>
 
Now to my actual question / my actual questions: 
  • How can I find out which HTTP resources are available?
  • Can I assume that this is how the HTTP requests are put together?
  • Is there any official documentation on this, and if so, where? (Unfortunately I have not found anything after hours of internet research)
  • Can I somehow debug this “mapping” between HTTP request and entity? 
Thank you very much for your help!
With kind regards
 
Christian
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at
    To see which records are available, let the entity return all data instead of referring to a single record by its key. In your case, use just {{d365_url}}/data/ProductDocumentAttachments.
  • CH-11120820-0 Profile Picture
    97 on at
    Hello Martin, 

    Yes, I already know that. But it's not quite what I'm trying to achieve and it's not really an answer to my questions.
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at
    Okay, so what do you mean by "How can I find out which HTTP resources are available"?
  • André Arnaud de Calavon Profile Picture
    300,917 Super User 2025 Season 2 on at
    Hi Christian,
     
    Not sure, but it can be caused by a time zone conversion of the date/time you provided. Instead of using the key fields, you can try using the query option $filter. You can then try to find a record without a value for the AttachedDateTime field. You can read more about this here: Open Data Protocol (OData) - Finance & Operations | Dynamics 365 | Microsoft Learn
  • CH-11120820-0 Profile Picture
    97 on at
    @Andre
    Yes, I am also familiar with this type of query. However, there is a small difference between the two queries. With a filter, I can at most get the result as a list with one element. Whereas sending the key fields results in the entity being output directly. Let me put it this way: this is not a problem for reading (just an extra step for my software). But if I want to update or delete something on the same entity, it is necessary in this way.
    The error message suggests that this endpoint does not exist. If a value was wrong (already had this with another entity) the error message would be correspondingly different. Which brings me back to the questions.
     
    @Martin
    I found out through testing that the error message comes up when I enter a route that doesn't exist, for example. Example:
    GET {{d365_url}}/data/FooEntity
    So for me it looks as if a corresponding route does not exist. At this point, documentation about which routes exist in D365FO would be really helpful.
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at
    It depends on what kind of route you mean.
     
    This thread seems to be about {{d365_url}}/data/ProductDocumentAttachments(ProductNumber='000666',DocumentAttachmentTypeCode='URL',AttachmentDescription='URL20240709-091930',AttachedDateTime='2024-07-09T07:19:31'), therefore the question "what are valid routes like this?" actually means "what are keys of all records contained in this entity?". The answer is that you need to return all records from the entity, which is done by not including any filters. If you wish, you can then create a scripting taking the data and creating an access URL for each record.
     
    Regarding {{d365_url}}/data/FooEntity, you can get the list of available entities by opening {{d365_url}}/data/FooEntity. If you don't find FooEntity there, you know that trying to use would fail. Or you can try the URL and check the response code.
  • CH-11120820-0 Profile Picture
    97 on at
    I think I'm finding it difficult to explain my problem sufficiently. I'll try to express it differently, perhaps in simpler terms first, and then I should be able to get further with the information. 

    If I want to use the “EngineeringChangeOrderHeaders” entity (as shown in the thread description), I have to specify the key fields stored in the metadata in the following format: 
    /data/EntitySet(KeyField1='value', keyField2='value')

    This works for most of the entities I have found. But not for “ProductDocumentAttachment”.
    Even if I specify all values defined as “key fields” in the notation described above, I get the error that the HTTP resource does not exist.
     
    How can I delete a “ProductDocumentAttachment” with the help of OData requests?
  • Verified answer
    Mariano G. Profile Picture
    3,598 on at
    I think your problem is in the datetime format, I've tested the entity PartyLocationPostalAddresses, and in my case I get the same error if I use quotations:
     
    D365_URL/data/PartyLocationPostalAddresses(PartyNumber='000000001',LocationId='000000001',ValidFrom='2024-10-15T10:45:45Z')
     
    but if I don't, it works:
     
    D365_URL/data/PartyLocationPostalAddresses(PartyNumber='000000001',LocationId='000000001',ValidFrom=2024-10-15T10:45:45Z), be aware of using 'Z' at the end of the date-time value (UTC).
     
    date time values don't uses quotations, just like integers or booleans
  • CH-11120820-0 Profile Picture
    97 on at
    That was it for me :) <3 

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans