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. array_column()用法

    <?php $arr = [ [ 'id' => 1, 'name' => 'a' ],[ 'id' => 2, 'name' => 'b', ], [ 'id' =&g ...

  2. UVA 11174 Stand in a Line,UVA 1436 Counting heaps —— (组合数的好题)

    这两个题的模型是有n个人,有若干的关系表示谁是谁的父亲,让他们进行排队,且父亲必须排在儿子前面(不一定相邻).求排列数. 我们假设s[i]是i这个节点,他们一家子的总个数(或者换句话说,等于他的子孙数 ...

  3. 利用Apache shiro SimpleHash 加密字符串

    1.导入包 import org.apache.shiro.crypto.hash.SimpleHash; 1 2.代码 import org.apache.shiro.crypto.hash.Sim ...

  4. python合并两个字典

    1.借助dict(d1.items() + d2.items())的方法 2.借助字典的update()方法,没有返回值 3.借助字典的dict(d1, **d2)方法 4.d3={**d1,**d2 ...

  5. moveDown()

    这里在判断边界时,判断的是 y == HEIGHT - 1. void moveDown(){ //定义变量存放人物下方的坐标 int dx, dy; //当下方没有元素时,直接return if(y ...

  6. Content:"\2715",特殊字符和图标

    原文 项目中用到的一些特殊字符和图标 html代码 <div class="cross"></div> css代码 1 2 3 4 5 6 7 8 9 10 ...

  7. centos7 python2升级python3

    安装前的准备环境 yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurse ...

  8. springboot 静态资源访问,和文件上传 ,以及路径问题

    springboot 静态资源访问: 这是springboot 默认的静态资源访问路径  访问顺序依次从前到后(http://localhost:8080/bb.jpg) spring.resourc ...

  9. 互斥锁lock、信号量semaphore、事件Event、

    1.互斥锁lock 应用在多进程中互斥所lock:互斥锁是进程间的get_ticket互相排斥进程之间,谁先枪占到资源,谁就先上锁,等到解锁之后,下一个进程在继续使用.# 语法: 上锁: lock.a ...

  10. Turbine Netflix

    Turbine是聚合服务器发送事件流数据的一个工具,用来监控集群下hystrix的metrics情况. 本实例是在consul做为服务发现时的配置. Turbine聚合器: 可以参照:https:// ...