cURL fetching an export from API intermittently failing with 500 Internal Server Error

Options
Sridattam
Sridattam Member, ALL USERS Posts: 2 New Contributor

Hi All,

 

We are trying to GET the exports from API but it is intermittently failing. At times when it is successful the response header will have content type returned as "Content-Type: application/octet-stream" and when it fails response header contains "Content-Type: application/json;charset=UTF-8"


FYR see below when it fails with 500:

> GET /2/0/workspaces/{workspaceID}/models/{modelID}/files/{fileID}/ HTTP/1.1
> Host: api.anaplan.com
> User-Agent: curl/7.79.1
> Accept: */*
> authorization: AnaplanAuthToken ***masked***
> Content-Type: application/octet-stream
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 11 Aug 2022 09:17:47 GMT
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< CF-Cache-Status: DYNAMIC
< Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< X-Content-Type-Options: nosniff
< Server: cloudflare
< CF-RAY: 738fe151dd65756a-LHR


FYR see below when it is success:

> GET /2/0/workspaces/{workspaceID}/models/{modelID}/files/{fileID}/ HTTP/1.1
> Host: api.anaplan.com
> User-Agent: curl/7.79.1
> Accept: */*
> authorization: AnaplanAuthToken ****masked***
> Content-Type: application/octet-stream
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Thu, 11 Aug 2022 09:17:52 GMT
< Content-Type: application/octet-stream
< Content-Length: 203
< Connection: keep-alive
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< CF-Cache-Status: DYNAMIC
< Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< X-Content-Type-Options: nosniff
< Server: cloudflare
< CF-RAY: 738fe16e0bd8779d-LHR

 
This started recently while there are no changes on the script, model ID, workspace ID and file export numbers remains same. Any help or pointers would be greatly appreciated.

Comments

  • Sridattam
    Sridattam Member, ALL USERS Posts: 2 New Contributor

    Hi @M.Kierepka 

     

    First of all, thank you so much for the response.

     

    Yes we do submit a export action (POST) in our script before requesting the files.

     

    I just ran the script and I see below output where taskState is shown as "IN_PROGRESS", you mean to say we should wait for this taskState to be COMPLETED before we can request (GET) for the files?

    {
      "meta" : {
        "schema" : "https://api.anaplan.com/2/0/models/{modelID}/objects/task"
      },
      "status" : {
        "code" : 200,
        "message" : "Success"
      },
      "task" : {
        "taskId" : "297A9BB774FD4C4787E55EF672B6CA2B",
        "taskState" : "IN_PROGRESS",
        "creationTime" : 1660235336530
      }
    }'