Rest Api response with FileName instead of FileId

New Contributor

Rest Api response with FileName instead of FileId

Hi Team,

I would like to know that instead of using the file id in the api get request can I use the filename as (xxxx.xls)

 https://api.anaplan.com/1/3/workspaces/8a81b0945cdbe1ec015ce678a3f60051/models/F54A3C7D6CE54A0F82EE7...

 

Thanks

Kandasamy

Message 1 of 11
10 REPLIES 10
Expert

Re: Rest Api response with FileName instead of FileId

You can specify the import data source or export name in the URL path instead of the numeric ID, although you may need to be careful with certain characters that must be encoded (the tool you use to access the API may handle this).

Message 2 of 11
New Contributor

Re: Rest Api response with FileName instead of FileId

Hi
To check the response I am using the Postman and in the postman I am using the Get method. In the endpoint I have given https://api.anaplan.com/1/3/workspaces/8a81b0945cdbe1ec015ce678axxxxxxx/models/F54A3C7D6CE54A0F82EE7... Page - Headcount Data Master - Report.xls
Under the Header I have given the Authorization. I would like to know what type of content type I need to select.

Thanks
Kandasamy
Message 3 of 11
Highlighted
Expert

Re: Rest Api response with FileName instead of FileId

Use application/octet-stream for the Accept header.

If the file is large then use the /2/0 API or the chunks endpoints instead.

Message 4 of 11
New Contributor

Re: Rest Api response with FileName instead of FileId

Hi
I tried in the Post man as you suggested , but I am getting not found error.
Please let me know if I missed anything

Thanks
Kandasamy
Message 5 of 11
Expert

Re: Rest Api response with FileName instead of FileId

It looks like you're missing the path component "/files", which should follow the model ID. Test using a numeric identifier first, then substitute the name for the numeric identifier.

Message 6 of 11
New Contributor

Re: Rest Api response with FileName instead of FileId

Hi
As you suggested in the postman I have given the end url as
https://api.anaplan.com/1/4/workspaces/8a81b0945cdbe1ec015ce678a3f60xxxx/models/420BD91A051443C6ADAC...
But I am getting the response as

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<title>Anaplan</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width = 960">
<link rel="shortcut icon" href="lib/anaplan/themes/original/images/favicon.ico">
<style type="text/css">
@import "lib/dojo/resources/dojo.css";

html {
overflow: auto;
}
</style>
</head>

<body>
<div id="pageWrap" class="pageWrap">
<div class="banner">
<h1>An error has occurred whilst processing your request:</h1>
</div>


<div>
<pre class="original">Not Found</pre>
</div>
<div>Please close your browser window and try again.</div>
<div>If the problem persists then please contact Anaplan Support.</div>
</div>
</body>

</html>


Message 7 of 11
New Contributor

Re: Rest Api response with FileName instead of FileId

Hi
I am getting the response for the .csv files but for the .xls file I am getting the Not found error as mentioned in my previous post

Thanks
Message 8 of 11
Expert

Re: Rest Api response with FileName instead of FileId

Now you've got /1/4 as a version instead of /1/3 or /2/0. That's not a valid API version, hence the not found error.

Message 9 of 11
New Contributor

Re: Rest Api response with FileName instead of FileId

Hi
I tried with 2/0 version to get the files https://api.anaplan.com/2/0/workspaces/8a81b0945cdbe1ec015ce678a3f60051/models/420BD91A051443C6ADACC...
but I am getting response as
{
"status": {
"code": 401,
"message": "Not Authorized."
}
}

When I tried version1/4 I am getting File not found.

Api version 1/3 is only giving response to me.

Thanks
Message 10 of 11