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. Comet OJ - Contest #11 B 背包dp

    Code: #include <bits/stdc++.h> #define N 1005 #define M 2000 #define setIO(s) freopen(s". ...

  2. 1250 Fibonacci数列(矩阵乘法)

    1250 Fibonacci数列 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 定义:f0=f1=1, fn=fn-1+fn ...

  3. FFT算法理解与c语言的实现

    完整内容迁移至 http://www.face2ai.com/DIP-2-3-FFT算法理解与c语言的实现/ http://www.tony4ai.com/DIP-2-3-FFT算法理解与c语言的实现 ...

  4. 早停!? earlystopping for keras

    为了获得性能良好的神经网络,网络定型过程中需要进行许多关于所用设置(超参数)的决策.超参数之一是定型周期(epoch)的数量:亦即应当完整遍历数据集多少次(一次为一个epoch)?如果epoch数量太 ...

  5. js反混淆

    var esprima = require('esprima') var escodegen = require('escodegen') content = "function _0x35 ...

  6. SQL和HQL 区别浅析!!!

    hql是面向对象查询,格式:from + 类名 + 类对象 + where + 对象的属性 sql是面向数据库表查询,格式:from + 表名 + where + 表中字段 1.查询 一般在hiber ...

  7. 单调队列优化dp(捡垃圾的机器人)

    /************************************************************************* > File Name: a.cpp > ...

  8. 报错1251 - Client does not support authentication protocol 解决办法

    # 1.容器中登录mysql,查看mysql的版本 status; # 2,进行授权远程连接(注意mysql 8.0跟之前的授权方式不同) GRANT ALL ON *.* TO 'root'@'%' ...

  9. Flutter移动电商实战 --(5)dio基础_引入和简单的Get请求

    这篇开始我们学习Dart第三方Http请求库dio,这是国人开源的一个项目,也是国内用的最广泛的Dart Http请求库. 1.dio介绍和引入 dio是一个强大的Dart Http请求库,支持Res ...

  10. 【SR汇总】算法时间效率

    1.SRCNN-0.39s SRCNN处理速度. 论文:Learning a Deep Convolutional Network forImage Super-Resolution 中,4.2节. ...