我正在尝试调用post请求将文件上载到Archer。请在下面找到我的代码:
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)
我收到以下错误:b'{“消息”:“请求包含实体正文,但没有内容类型标头。此资源不支持推断的媒体类型“应用程序/八位字节流”,“ExceptionMessage”:“没有MediaTypeFormatter可用于从媒体类型为“application/octet stream\”的内容中读取类型为“AttachmentWrapper\”的对象。”,“ExceptionType”:“System.Net.Http.UnsupportedMediaTypeException”,“StackTrace”:“在System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent内容,类型,IEnumerable1格式化程序,IFormatterLogger格式化程序记录器,CancellationToken CancellationToken)\\r\\n在System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage请求,类型类型,IEnumerable
1格式化程序,IFormatterLogger格式化程序记录器,CancellationToken CancellationToken)“}”状态代码:415
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
with open("1.png", "rb") as img_file:
data = base64.b64encode(img_file.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",
}
BODY ={
"AttachmentName":"1.png",
"AttachmentBytes":data,
"IsSensitive":"true"
}
response = requests.request("POST", url, data=BODY, headers=headers, verify = False)
我还尝试了以下方法:
BODY = '"Attachment Bodie" {
"AttachmentName": "testdoc.txt",
"AttachmentBytes":"'+str(data)+'",
"IsSensitive":"true"
}'
但是得到同样的错误
啊,我意识到你发送的数据格式不正确。其内容应如下:
{
"AttachmentName" : "myFile.docx",
"AttachmentBytes" : "[base64 here]"
}
纳卡特拉,你有没有事先把上传的文件转换成Base64?
我正在尝试在Spring Boot中使用WebClient制作API POST Request。但是我无法使用JSON正文发出我想要的请求并以JSONObject的形式接收响应。 JSON正文: 服务类别- 工作区模型- 主通话- 我需要发送一个JSON主体列表,作为主体post请求。请帮我做帖子请求提前谢谢
<?php $requestBody = array( 'lang' => 'php', 'ver' => 'any' ); $http = HttpRequest::newSession(); $response = $http->post('http://www.baidu.com/', $requestBody);
具体来说,我希望下面的示例可以工作: 如果这不是POST请求的正确方式,请告诉我如何在FastAPI中从上传的CSV文件中选择所需的列。
我使用Postman(chrome扩展)来测试这个REST服务,并且我能够成功地测试GET和DELETE:<code>http://localhost:8080/mt-rest/rest/user/321,但不是POST,即使在给出表单数据之后也是如此。我得到..服务器拒绝了此请求,因为请求实体的格式不受请求方法的请求资源的支持。我在这里做错了什么? 更新: 在我的POST方法中,我从@Reque
我正在尝试使用JQuery在Ajax中向请求添加头。 以下是代码:- 然后我使用了要求(要求是chrome火狐插件,我们可以手动添加一个标题到请求)。 手动添加标题后:- 在这两个pics请求头中,“ACCESS-CONTROL-request-HEADERS”中都有x-auth-token,但第二个pic中有“x-auth-token”头和头值,而第一个pic中没有。 所以我的问题是如何使用JQ
我正在尝试创建一个使用在我的数据库中创建新对象的REST API。我正在使用Slim框架。 问题是我不确定在我的< code>POST方法的这些行中到底应该放些什么: 我的完整路由是: 在表< code>cars中有对象< code>Car。 我应该这样说吗?: 我有点困惑,因为在我之前看到的教程中,在方法中,他们没有任何对路由中变量名称的引用。例如,如果他们使用,他们没有在其路由中声明任何名为的