You can use POSTMAN or FIDDLER for any of the testing. I personally like POSTMAN.
I assume that you have already gone through pages on READ operations. If not, please go through all that for better understanding of upcoming discussion on CREATE,UPDATE and DELETE operations in Dynamics 365 for operations(D365O).
Reading through data entities was fun, isn't it. But as a developer you must be willing to do more than just reading the data using Data entities.
Microsoft has done commendable work in whole data entity framework in D365O, it now can be used as point of entry for other operations such as create, update and delete. This a big relief considering AIF is practically a history for D365O.
Although there are other ways also to deal with data inside D365O, I find using Data entities the easiest.
I have created a custom table named 'BeaconService' for my testing purpose.
1. CREATE operations:
In Odata terminology, D365 CREATE operation can be referred as POST operation. Yes, you are right, that means you have to setup a method type to POST.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice
Set the Authorization code prefixed by 'bearer'
Then Set the body, keeping mandatory fields like BeaconID(in my case) and dataareaId as shown below.
I assume that you have already gone through pages on READ operations. If not, please go through all that for better understanding of upcoming discussion on CREATE,UPDATE and DELETE operations in Dynamics 365 for operations(D365O).
Reading through data entities was fun, isn't it. But as a developer you must be willing to do more than just reading the data using Data entities.
Microsoft has done commendable work in whole data entity framework in D365O, it now can be used as point of entry for other operations such as create, update and delete. This a big relief considering AIF is practically a history for D365O.
Although there are other ways also to deal with data inside D365O, I find using Data entities the easiest.
I have created a custom table named 'BeaconService' for my testing purpose.
1. CREATE operations:
In Odata terminology, D365 CREATE operation can be referred as POST operation. Yes, you are right, that means you have to setup a method type to POST.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice
Set the Authorization code prefixed by 'bearer'
Then Set the body, keeping mandatory fields like BeaconID(in my case) and dataareaId as shown below.
{ "EndTime": 0, "BeaconNum": "DA:AF:A9:FD:Y6:T4", "OfferId": "ST100006", "Description": "25% flat discount for your amazing audio experience", "EffectiveDate": "2015-12-25T12:00:00Z", "StartTime": 0, "dataAreaId": "usrt", "Category": "Headphones", "Offer": "headphones on discounted rate", "Brand": "Sony" }
Now execute it (click on Send button if using POSTMAN).
This will give same output on the postman and error if any. Now you can go to the database or D365 screen to see the data.
2. UPDATE Operations
In Odata terminology, D365 UPDATE operation can be referred as PATCH operation.
i.e., you have to setup method type as PATCH.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice(BeaconNum='DA:AF:A9:FD:Y6:T4',dataAreaId='usrt')
Difference in the URL as you can see is, you'll have to include your primary key along with datareaid.
Now, Set the Authorization code prefixed by 'bearer'
Then Set the body as below, here you do not have to include primary keys
i.e., you have to setup method type as PATCH.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice(BeaconNum='DA:AF:A9:FD:Y6:T4',dataAreaId='usrt')
Difference in the URL as you can see is, you'll have to include your primary key along with datareaid.
Now, Set the Authorization code prefixed by 'bearer'
Then Set the body as below, here you do not have to include primary keys
{ "Category": "Earphones" }
Now execute it (click on Send button if using POSTMAN).
3. DELETE Operations
In Odata terminology, D365 UPDATE operation can be referred as DELETE operation.
i.e., you have to setup method type as DELETE.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice(BeaconNum='DA:AF:A9:FD:Y6:T4',dataAreaId='usrt')
Here also, you'll have to include your primary key along with datareaid.
Now, Set the Authorization code prefixed by 'bearer'
Leave the body blank here.
i.e., you have to setup method type as DELETE.
URL would look like this
https://*******devaos.cloudax.dynamics.com/data/Beaconservice(BeaconNum='DA:AF:A9:FD:Y6:T4',dataAreaId='usrt')
Here also, you'll have to include your primary key along with datareaid.
Now, Set the Authorization code prefixed by 'bearer'
Leave the body blank here.
Then execute it (click on Send button if using POSTMAN).
--------------------------------------------------------------------------------------
I am done here.
Thanks for your time!!!
Shoot the message if anything is missing or needed to be modified.
Wonderful blog! Do you have any suggestions for aspiring
ReplyDeletewriters? I'm planning to start my own website soon but I'm a little lost on everything.
Would you advise starting with a free platform like Wordpress or go
for a paid option? There are so many options out there that I'm completely
confused .. Any recommendations? Thank you!
Hey buddy, I am surely not a best person to advise on that. However, there are so many blogs to focus especially on writing.
DeleteFor starters, its always best to opt for free platforms and later on when you are comfortable and have enough readers, you can switch to paid versions for more convenience and options.
I am no longer positive the place you are getting
ReplyDeleteyour info, however great topic. I must spend some time learning much more or working out more.
Thanks for excellent info I was searching for this information for my mission.
I believe there would be some reason for your disagreement here. If you can point out few things, I can surely work on that for this and future topics...
DeleteHow can I make it so that I can post multiple objects using Odata in D365FO? Seems like this crud only works with single object
ReplyDeleteIt works for multiple objects too...you just have to pass objects in an array[] with multiple opening'{' and closing'}' braces separated by comma(,)...
DeleteIf you have a more complex scenario, i'll suggest you to use custom services..
Hi, Thanks for such a wonderful post. Very very useful.
DeleteI have tried sending multiple objects as you mentioned but could not succeed. Can you pls help me here. Below is the 'POST' request i used to create multiple customer groups.
{
[{
"CustomerGroupId":"15","Description":"Wholesales customers","DefaultDimensionDisplayValue":"","ClearingPeriodPaymentTermName":"Net30","PaymentTermId":"Net30","IsSalesTaxIncludedInPrice":"No","WriteOffReason":"","TaxGroupId":"","dataAreaId":"usmf"
},
{
"CustomerGroupId":"16","Description":"Wholesales customers","DefaultDimensionDisplayValue":"","ClearingPeriodPaymentTermName":"Net30","PaymentTermId":"Net30","IsSalesTaxIncludedInPrice":"No","WriteOffReason":"","TaxGroupId":"","dataAreaId":"usmf"
}]
}
It produced the below error
{"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "Invalid property identifier character: [. Path '', line 2, position 1.",
"type": "Newtonsoft.Json.JsonReaderException",
I am sorry...I was extremely busy with work..... Are you able to use it for single object?..Unfortunately i don't have d365 access for now and so not able to verify it for you...
DeleteHi,
Deleteok No problem :)
It works for only a single object but not for multiple objects.
Hello
ReplyDeleteHow could I do to publish the token, so I will not be running the visual every time I want to run the webServices?
Is there any way to do this?
Hi, Indeed you can achieve this just by writing a small web application and later publish it on IIS locally to use within your organization or you can be more liberate and use Azure to publish it over internet....
DeleteHello
ReplyDeleteCould you please guide me to do what you tell me, I am trying to make the WebServices application not ask me for the token authentication but I could not find the solution
I thank you very much if you can send me more information
Hi michael, i am really sorry for the late reply. Hope you would have already got the solution to create a webservice in order to get token. If not, please send me an email
Deletevery useful post..
ReplyDeleteMicrosoft dynamics 365 for finance and operations
Dynamics 365 finance and operations
D365 finance and operations
Dynamics 365 training
Microsoft dynamics 365 training
Thanks for sharing this article..Its really nice and useful information.
ReplyDeleteDevOps Training
DevOps Online Training
DevOps Training in Hyderabad
DevOps Training in Ameerpet
Thanks for sharing this information.Very Usefull Blog.
ReplyDeleteDevOps Training
DevOps Online Training
DevOps Online Training in Hyderabad
DevOps Online Training institute
DevOps Training in Hyderabad
This information is really awesome thanks for sharing most valuable information.
ReplyDeleteDevOps Training
DevOps Online Training
DevOps Online Training in Hyderabad
DevOps Online Training institute
DevOps Training in Hyderabad
DevOps Training institute in Ameerpet
DevOps Project Training
DevOps Training in Ameerpet
DevOps Training institute in Hyderabad
DevOps Course in Hyderabad