I am trying to call a post request to upload a file to Archer. Please find my code below :
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
data = open('testdoc.txt','rb').read()
url = "http://rsaarcher/platformapi/core/content/attachment" #my archer url
token = "<my session id token>"
headers = {
'Accept':'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Authorization': 'Archer session-id="'+token+'"',
'content-type': "application/json;",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=data, headers=headers, verify = False)
print(response.content)
print(response.status_code)
I am getting the following error :
b'{"Message":"The request contains an entity body but no Content-Type header. The inferred media type \'application/octet-stream\' is not supported for this resource.","ExceptionMessage":"No MediaTypeFormatter is available to read an object of type \'AttachmentWrapper\' from content with media type \'application/octet-stream\'.","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\\r\\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable
1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}'
Status code : 415