We use a session cookie as anonymous ID for your visit. View our privacy policy to learn more.

Welcome Guest : please login to be able to post Search | Active Topics | Log In | Register

Batch operations against SageERP Accpac oeorders Options · View
Benjamin Haskell
Posted: Wednesday, June 27, 2012 6:10:06 PM
Rank: Member

Joined: 6/14/2012
Posts: 4
I'm trying to perform batch operations against the Accpac SData API. In the long run, we'd like to be able to update multiple line items simultaneously, but in playing with the API, I'm just attempting to retrieve two oeorders at the same time.

No matter what I've tried, I can't avoid the following error:

Code:
<?xml version='1.0' encoding='UTF-8'?>
<sdata:diagnoses xmlns:sdata='http://schemas.sage.com/sdata/2008/1'>
  <sdata:diagnosis>
    <sdata:severity>error</sdata:severity>
    <sdata:sdataCode>BadUrlSyntax</sdata:sdataCode>
    <sdata:message>The request cannot be executed via the specified HTTP method</sdata:message>
  </sdata:diagnosis>
</sdata:diagnoses>


The relevant information (that I can think of) for my attempt to get two orders is as follows:

Code:
URL: https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders/-/$batch
Method: POST
Headers:
  Content-Type: application/atom+xml; type=feed; charset=UTF-8


The body of the POST request is as follows (domain + company names sanitized):

Code:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:sdata="http://schemas.sage.com/sdata/2008/1"
      xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
  <id>https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders/-/$batch</id>
  <title/>
  <entry>
    <id>https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders('1601')</id>
    <title/>
    <content/>
    <http:httpMethod>GET</http:httpMethod>
  </entry>
  <entry>
    <id>https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders('1665')</id>
    <title/>
    <content/>
    <http:httpMethod>GET</http:httpMethod>
  </entry>
</feed>


Attempting to GET either of the individual //entry/id values works. E.g. I can GET
Code:
https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders('1601')


Does anyone see something obvious that I'm missing?

Thanks,
Ben
Darron Cockram
Posted: Monday, July 02, 2012 4:05:35 AM
Rank: Advanced Member

Joined: 10/13/2010
Posts: 117
I'm not familiar with Accpac but have you checked that the sme:batchingMode is set for that resource kind? The other thing to check would be the URL you are using as it looks incorrect to me. I would have thought that the batch URL would be https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders/$batch.
Benjamin Haskell
Posted: Thursday, July 12, 2012 8:32:09 AM
Rank: Member

Joined: 6/14/2012
Posts: 4
Sorry, didn't see your response until today.

I'm not sure where I picked up the '/-' before '/$batch' in the URL -- probably from adapting a generic SData example to Accpac. It still fails in the same way without it.
Darron Cockram
Posted: Friday, July 13, 2012 3:38:11 AM
Rank: Advanced Member

Joined: 10/13/2010
Posts: 117
Did you check what value the sme:batchingMode attribute is set to for that resource kind in the schema? Also, what response are you getting from the request?

As it's a GET request you may be able to take a slightly different approach and use a standard GET request. Something along the lines of this:

https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders?where=id%20eq%20'1601'%20or%20id%20eq%20'1665'

or if the Accpac adapter supports the intermediate level query language something like this:

https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders?where=id%20in%20('1601','1665')
Benjamin Haskell
Posted: Sunday, July 15, 2012 12:35:55 PM
Rank: Member

Joined: 6/14/2012
Posts: 4
The schema from https://example.com/SDataServlet/sdata/sageERP/accpac/SAMINC/oeorders/$schema appears to support batching: sme:batchingMode='syncOrAsync'.

Unfortunately, I'm only using 'GET' for the purpose of making the example simpler during development. We actually want to use a batch POST to update several items atomically.

Benjamin Haskell
Posted: Sunday, July 15, 2012 12:38:20 PM
Rank: Member

Joined: 6/14/2012
Posts: 4
And an example response, status = 400.

Quote:
<?xml version='1.0' encoding='UTF-8'?>
<sdata:diagnoses xmlns:sdata='http://schemas.sage.com/sdata/2008/1'>
<sdata:diagnosis>
<sdata:severity>error</sdata:severity>
<sdata:sdataCode>BadUrlSyntax</sdata:sdataCode>
<sdata:message>The request cannot be executed via the specified HTTP method</sdata:message>
</sdata:diagnosis>
</sdata:diagnoses>
Darron Cockram
Posted: Monday, July 16, 2012 3:10:44 AM
Rank: Advanced Member

Joined: 10/13/2010
Posts: 117
From that error message I'd surmise that, whilst the endpoint does support batch requests, it does not support batch GET requests - but may support PUT/POST/DELETE. Unfortunately the metadata exposed via the schema does not allow for this level of granularity to be expressed so the only way to know for sure would be to try different request verbs.

Have you tried issuing a PUT/POST/DELETE request against the same end point?
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS