python+request 发送post请求:msg返回"Content type 'application/octet-stream' not supported"

一、问题源代码:

1、代码:

 import requests
import json
url = "http://47.106.203.20:8000/ssposs2/api/auth/login"
par = {
"account":"ceshi",
"pwdMd5":"e10adc3949ba59abbe56e057f20f883e"
}
r = requests.post(url,data=json.dumps(par))#因为请求传送的参数是josn格式,所以这里要用到json.dumps()
print(r.text)#请求返回内容
print(r.status_code)#请求返回状态

2、运行结果:

 {"result":false,"msg":"Content type 'application/octet-stream' not supported","code":"E1000","data":null}
200

二、post请求一般有4种请求,分别是:

1、application/x-www-form-urlencoded浏览器原生表单

2、multipart/form-data

3、application/json

4、text/xml文本格式

所以需要加上请求内容类型Content-Type: XXXXX

三、修改后代码和运行结果

1、代码:

import requests
import json
url = "http://47.106.203.20:8000/ssposs2/api/auth/login"
par = {
"account":"ceshi",
"pwdMd5":"e10adc3949ba59abbe56e057f20f883e"
}
r = requests.post(url,data=json.dumps(par),headers={'Content-Type':'application/json'})
print(r.text)#请求返回内容
print(r.status_code)#请求返回状态

2、运行结果:

{"result":true,"msg":null,"code":null,"data":"login success. "}
200

Python +requests 关于post请求返回报错的更多相关文章

  1. Python+requests 发送简单请求--》获取响应状态--》获取请求响应数据

    Python+requests 发送简单请求-->获取响应状态-->获取请求响应数据 1.环境:安装了Python和vscode编译器(Python自带的编译器也ok).fiddler抓包 ...

  2. ajax提交数据服务端返回报错

    报错如下: if response.get('X-Frame-Options') is not None:AttributeError: 'str' object has no attribute ' ...

  3. python requests方法post请求json格式处理

    方法如下: import requestsimport json data = {    'a': 123,    'b': 456} ## headers中添加上content-type这个参数,指 ...

  4. inceptor es表插入成功,返回报错you should set transaction.type before any DCL statement

    在finebi下用星环的连接驱动去写inceptor es表,发现插入能成功,但是返回一个报错: Caused by: java.sql.SQLException: Error to commit. ...

  5. laravel 浏览器谷歌network返回报错html

    laravel 在谷歌报错的时候会返回html,对于调试来说很不方便.原因是在于: 这里返回的格式是json,但是报错时候返回的是整个html所以 相对路径: app\Exceptions\Handl ...

  6. 大概看了一天python request源码。写下python requests库发送 get,post请求大概过程。

    python requests库发送请求时,比如get请求,大概过程. 一.发起get请求过程:调用requests.get(url,**kwargs)-->request('get', url ...

  7. python+pytest接口自动化(4)-requests发送get请求

    python中用于请求http接口的有自带的urllib和第三方库requests,但 urllib 写法稍微有点繁琐,所以在进行接口自动化测试过程中,一般使用更为简洁且功能强大的 requests ...

  8. python非转基因HTTP请求库--Requests: 让 HTTP 服务人类

    快速上手 迫不及待了吗?本页内容为如何入门 Requests 提供了很好的指引.其假设你已经安装了 Requests.如果还没有,去安装一节看看吧. 首先,确认一下: Requests 已安装 Req ...

  9. Python使用requests模块访问HTTPS网站报错`certificate verify failed`

    使用requests模块访问HTTPS网站报错: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Nam ...

随机推荐

  1. learning armbian steps(7) ----- armbian 源码分析(二)

    从compile.sh开始入手: SRC="$(dirname "$(realpath "${BASH_SOURCE}")")" # fal ...

  2. [Loj] 数列分块入门 1 - 9

    数列分块入门 1 https://loj.ac/problem/6277 区间加 + 单点查询 #include <iostream> #include <cstdio> #i ...

  3. 第二章 Python数据导入

    数据导入 数据存储的两个地方: 文件 CSV.Excel.TXT(学习层面) 数据库(公司实战层面) Mysql.Access.SQL Server 导入CSV文件 CSV文件第一行是列名,第二行到最 ...

  4. IntelliJ IDEA-配置文件位置

    关于配置文件的位置 一旦开始使用IDEA之后,就需要做很多的配置相关工作,使得IDEA越来越符合你的个人习惯,让你使用起来得心应手.而这些配置信息,都保存在C盘,比如我的就会默认保存在如图所示的位置 ...

  5. JS基础_数组的遍历

    遍历:将数组中所有的元素都取出来 1.for循环 var arr = ["1","2","3"]; for(let i=0;i<arr ...

  6. 2 ArrayList 详解

    List 是有序.可重复的容器.List中每个元素都有索引标记,可以根据元素的索引标记访问元素,从而精确控制这些元素. List 接口常用的实现类:ArrayList.LinkedList.Vecto ...

  7. SpringBoot整合guava缓存

    1.pom文件 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  8. 解决Powershell中不能运行脚本问题

    问题: powershell中不能执行脚本,提示‘because running scripts is disabled on this system’ 原因: powershell中默认的execu ...

  9. LeetCode 最长公共前缀(探索字节跳动)

    题目描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow ...

  10. hadoop新旧节点

    注意:黑白名单只出现在名称(nn)节点<!-- 白名单 --><property><name>dfs.hosts</name>/Users/yangya ...