3
$\begingroup$

I'm trying to perform a multiple element GET request from an alfresco database of elements. The way we have it set up is if a GET request is made with a body, it will return the elements listed in the body. I have the following code, and everything works as it should up until the URLFetch:

Begin["`Private`"];

getElements[server_,branch_,site_,elementIDs_]:=( 
    (*elementIDs is a list of strings*)
  url=StringJoin[server,"/alfresco/service/workspaces/",branch,"/elements"]
 ; assoc=<|"elements"->Association/@Thread["id"->elementIDs]|>
 ; jsonElements = ExportString[assoc,"RawJSON"]
 ; Return @ URLFetch[
       url
     , "Method"->"GET"
     , "Body"->jsonElements
     , "Headers"->{
           "Content-Type"->"application/json;charset=UTF-8"
         , "Content-Length"->"0"
         , "Accept"->"application/json;charset=UTF-8"
       }
    ];
)

End[];

I would like to use URLExecute, but it returns the following error:

Import::fmterr: Cannot import data as JSON format.

When using URLFetch, it is returning "Could not complete DB transaction, see Alfresco logs for details." I dont know if it's a problem with my code, Mathematica, or the api.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

EDIT 04/25/2017: I got a response to the bug report. Apparently Mathematica developers have resolved the issue on a future release.


Alright, I ran the code using curl and even checked my tcp logs when executing it in Mathematica. It seems that Mathematica is taking the headers and making them lower-case when sending to the url. Normally this wouldn't matter, but some APIs (like ours) are case sensitive.

So "Content-Type" is being sent as "content-type" (cant remember if I used a hyphen). This is producing the error.

I've catalogued the problem in a bug report sent to Wolfram Support. I'm leaving the post up until they resolve the issue just in case either anyone knows a workaround or someone has a similar problem and cant figure out the cause.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.