I've been attempting to get the file ID from a model using the following curl code adapted from the Anaplan API docs in Apiary.
curl -v --include --header "Authorization: Basic encoded_username:password" --header "Content-Type: application/json" "https://api.anaplan.com/1/3/workspaces/8a81b09c637a13f70163989092ab080f/models/BB491FD8A9342FF815249BCD6C58B7A/files"
Note: I am actually using the Base64 encoded form of my login credentials, only left the pseudo-code in there for obvious reasons.
When running this script I've only been able to get a 500 Internal Server Error and the HTML code for the webpage that I would imagine the error is intended to take the user to. I noticed the HTML code contains an additional piece of information that the error is caused by an "Illegal Argument".
I've adapted the script many many times now to try and parse out if there's something in this little bit of code that's triggering the error and the script is taken straight from the API doc so I'm at a loss for what this error is and how to get around it.
Has anyone else run into this at all and can provide some assistance/clarification?
Most likely you're encoding the Authorization header incorrectly. Curl can do that for you, so replace that --header with
and see if it works. The Content-Type header is only relevant if you're providing content in a PUT/POST request; perhaps "Accept: application/json" is what you wanted?
I tried using the --user tag instead of the --header "Authorization" and using "Accept: application/json" but they both return with an invalid authentication error so it would seem the Authorization field is required to get the File ID. I also noticed when I inspect the request process (adding -v to the cURL script) the data being returned from the server says Content-type is text/html rather than the application/json that's returned with the Workspace and Model ID requests.
What stands out is the cURL script in the API docs to get a File ID through the API is different than getting IDs for other objects like Workspaces and Models. I thought this might have had something to do with whether a file is classed as private or default but after testing on that it still returns the 500 Internal Server Error.
Well it looks like it's working now without any changes to my original script. I don't know if there was a change on the server's side but I'm able to bring the File ID data in now so we're good to go!
As far as the cURL encoded approach using the --user tag, you're right, I probably had it formatted wrong when using it in the request to get the File ID's. I was passing in both my username and password as can be done with the scripts requesting Workspace/Model IDs and it looks like the File ID request would require only the email address in order to prompt the user for their password.
Either way, I'm just glad it works now!