REST api to Execute Import Action Error
I have a java application where I'm trying to execute an import action using the REST API and am getting the returned status of 415 (unsupported media type) from the post. I'm following the syntax defined in the online help: http://docs.anaplan.apiary.io/#reference/import/post-acts-as-the-execute-command-to-start-the-operation-and-it-also-receives-the-task-id-value-as-a-json-object-get-receives-a-list-of-the-tasks-as-a-json-array/execute-the-import-task : Client client = ClientBuilder.newClient(); Entity payload = Entity.text(""); Response response = client.target("https://api.anaplan.com/1/3/workspaces/{workspaceID}/models/{modelID}/imports/{importId}/tasks/") .request(MediaType.TEXT_PLAIN_TYPE) .header("Authorization", "Basic encoded_username:password") .header("Accept", "application/json") .post(payload); and replacing {workspaceID}, {modelID}, and {importId} with the values from the GET API calls. Tried other media types but still getting the same error. Any help is appreciated.
Answers
-
I had had the same issue with this, using python. I found that I needed to add a locale parameter to my post request, see below my python script it is the values parameter that I added.
url = https://api.anaplan.com/1/3/workspaces/8a81b09d5a9b7d7d015aaa016a874eeb/models/5EFF3AE4312A4F4FB8E081E6421C6DE3/exports/116000000000/tasks'
headers = {'Accept':'application/json'}
values = {'localeName':'en_US'}
r = requests.post(url,json=values,headers=headers,auth=('username','password'))Hope this helps.
0 -
If something goes wrong in an API request, an error or a warning will be thrown (although the HTTP response will usually still be 200 OK ). Warnings are thrown for non-fatal conditions such as invalid parameters, whereas errors are only thrown for fatal conditions.
0