Inconsistent response for Anaplan APIs

Hi,

While trying with Anaplan API GET method to export data from model, I am getting inconsistent response.

i. I was getting 9 columns earlier based on which we designed our database schema, now I am getting 8 columns in response.

ii. While trying with another user, I am getting all 9 columns in response.

iii. If I run export from UI, I am getting 9 columns in response.

iv. For 1 file id, I get chunk size as 29 for my user while for other user id I get chunk size as 0.

Can you please help to understand this behavior?

Thanks

Best Answers

  • rajanirath
    Answer ✓

    hi,

    I realized, I should first run a post method to refresh the export and then run the GET api to download file. It worked fine for me.

  • I recommend you take advantage of the MetaData APIs for Imports and Exports.

     

    I have done the following in my implementations:

    1. Call the MetaData REST API for a given Import
    2. Verify the column count and column headers match my internal code
      1. ie, My java POI excel parser is expecting header "Email, Last Name, First Name, address"
      2. Continue processing if column count and headers match ELSE fail out with a clear error message (I show expected vs actual column headers in the log)

    In my prod setup,I export data for ~10 workspaces and ~20 models via hourly batches and found the above very useful. Once a model builder changed an export in DEV and didn't relay the same to Eng Team however our DEV integration run caught it b/c of the MetaData check...I sent a nicely worded email to the model builder and it was fixed in 1 hr 🙂

     

    See here https://anaplanbulkapi20.docs.apiary.io/#reference/import

     

    Get the metadata for an import definition

    /workspaces/{workspaceID}/models/{modelID}/imports/{importID}

    You can use the API to obtain metadata for an import definition for module and list imports using the import ID. This enables you to use mappings on your imports without querying the import file itself. You can retrieve:

    • Name

    • Type

    • Source

    • Column Count

Answers

  • @ben_speight  Can you please help @rajanirath 

  • Hi,

     

    The API respects the user rights. from what you explain, the user running the API might not have all the

    access. Try running the API calls with the users you use for the GUI.

     

    These columns, are they a list ? My guess is that list has selective access enabled.

  • Hi,

    The response is in CSV format.I have verified that with my ID in gui I am getting all the columns in downloaded file. Its when I do API call, I see 1 column missing.

    With user2, I see all the columns in GUI and API response as well.

    Let me know if want me to provide any additional detail

  • When a user runs an export in the API, it writes to a file that is specific to that export and user.
    If you execute an export (by POSTing to the .../exports/id/tasks endpoint and polling the task status) as user A then retrieve the file content as another user B then you won't receive the results of user A's export execution.
    If you are running and then retrieving the export as the same user, but get a different number of columns depending on the user, there could be permissions differences, but these would also be reflected when run from the UI. So lets start by looking at how exactly you are running the export through the API.

  • then it is clearly a rights issue.
    Make sure the user running API calls has all the necessary access to the lists, especially the ones that you call "columns"