From here, things are pretty straightforward. It’s just basic REST with a couple of pointers. By convention, REST treats collections of things like folders on a web server, at least when it comes to the URL. See below for some examples working with a demo item (in JSON format) to get a hang of how the calls are made.
1. Create an item
Method: POST (note: not PUT)
URL: https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items(note: the item number isn’t included in the URL)
Headers:
Content-Type: application/json
Accept: application/json
Body:
{
“Payload”:{
“ItemNumber”:”DEMO”,
“ItemShortName”:”Demo Item”,
“ItemDescription”:”Demo Item created with SBA”,
“UOfMSchedule”:”EACH”
}
}
A couple of things to note here. First, the information you’re sending will always be in a sub-object calledPayload. Second, the procedures do vary somewhat from the functionality we’re used to in the older web services or eConnect. From what I can tell (in this case, at least) defaulting values from an inventory class aren’t really supported.
2. Retrieve all items
Method: GET
URL: https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items
This will return the items in XML format. To return them in JSON format, just append .json to the end of the URL: https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items.json
3. Retrieve a single item
Method: GET
URL:https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items(ItemNumber)
4. Update an item
Method: PATCH
URL:https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items(ItemNumber)
Headers:
Content-Type: application/json
Accept: application/json
Body:
{
“Payload”:{
“ItemNumber”:”DEMO”,
“ItemShortName”:”Demo Item”,
“ItemDescription”:”Demo Item updated with SBA”,
“UOfMSchedule”:”EACH”
}
}
*Note* Although this functionality is specific by procedure (it just depends on how that given procedure was coded), in the case of items, although the procedure supports merging a partial item object (in other words, it will update ItemDescription if you include it in your Payload object but will not change it if that property is simply missing), it does required field validation only against the supplied object. Therefore, you have to pass all required fields even if the only one you want to update is ItemDescription.
5. Remove an Item
Method: DELETE
URL:https://mymachine:myport/GPService/Tenants(Test)/Companies(Fabrikam,%20Inc.)/Inventory/Items(ItemNumber)
6. Discovery Service
Finally, a lot more detail for the methods that are available can be found at https://mymachine:myport/GPService/Tenants(Test)/Companies(CompanyName)/Help. This has all of the methods by product and some information about the call and response.