Help needed with Rest API file upload (using R if possible)

Options
sunilrinald
sunilrinald Member, ALL USERS, Partner, Certified Model Builder Posts: 4 New Contributor

Hello everyone, I am trying to upload a file onto anaplan from R and haven't been successful for quite a bit of time. 

 

I will list down the steps I have taken and it would be greatly appreciated if anyone can help

 

1. Created a file in anaplan and set the option to "Admins Only". The file name is driver_coeff_template.csv

sunilrinald_0-1618919736740.png

 

2. Created an import action that uses this file to update data in a module

 

sunilrinald_1-1618919862036.pngsunilrinald_2-1618919878134.png

 

3. Here are the actions that i run through R. I will attach the script that has i built using the RestAPI documentation. The first one is authentication, i am able to login and generate a token. 

 

4. Using GET to fetch file details

5. Using POST to set chunk count to -1. (The file that needs to be uploaded is very small usually ~100 KB)

6. Using PUT to upload file. The upload file has data as shown below in the screenshot. Also this step always seems to return NULL as response in R. 

sunilrinald_3-1618920597400.png

 

 

 

 

7. Using POST to mark upload as complete. Once this is done, i checked out the file in anaplan 

sunilrinald_4-1618920721484.pngsunilrinald_5-1618920820076.png

It seems that part of the file has been loaded which is the first column "Estimate" but the row positions are changed and i am missing the other columns. 

 

Would really help any help on this and as mentioned before, i have attached the R code as well in a text file. The code simply uses the URLs for the api and has functions for headers as well as body that has to be sent in case anyone find it hard to understand. I have looked at the discussion a few times https://community.anaplan.com/t5/Anaplan-Platform/Uploading-file-Via-REST-API-and-Triggering-Imports/m-p/51791#M7821 as well as the Rest API videos in https://community.anaplan.com/t5/How-To/RESTful-API-How-To/ta-p/33579 but haven't been able to get the upload right. 

 

 

Comments

  • sunilrinald
    sunilrinald Member, ALL USERS, Partner, Certified Model Builder Posts: 4 New Contributor

    hi ben, @ben_speight  could you please elaborate a bit more on this, finding it hard to understand as i am not very well versed with APIs 

  • sunilrinald
    sunilrinald Member, ALL USERS, Partner, Certified Model Builder Posts: 4 New Contributor

    Let me try this @ben_speight  and will let you know what happens

  • sunilrinald
    sunilrinald Member, ALL USERS, Partner, Certified Model Builder Posts: 4 New Contributor

    thank you so much @ben_speight , this worked out perfectly for a single chunk file. Been at this for a while so really appreciate the help.