微信小程序之请求400(Bad Request)
2017-09-11 00:24
381 查看
微信API
对于header['content-type']为
application/json的数据,会对数据进行json序列化
对于
header['content-type']为
application/x-www-form-urlencoded的数据,会哦将数据转换成
query string (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)
示列代码
以下是我微信小程序中的示列代码//请求URL wx.request({ url:"https://api.douban.com/v2/movie/top250", data:{}, header: { 'content-type': 'application/json' // 默认值 }, success:function(res){ wx.hideToast(); console.log(res.data); } });
编译错误
以下是编译后出现的错误解决问题
我在request里的header修改一下如下:header: { //'content-type': 'application/json' // 默认值 //这里修改json为text json的话请求时会返回400(bad request) 'content-type': 'application/texts' },
修改后调试如下
相关文章推荐
- 微信小程序解决请求: 400 (Bad Request)错误
- 关于微信小程序request请求400错误
- 解决·微信小程序开发-网络请求报Invalid request 400错误
- 微信小程序访问豆瓣电影api 400 (Bad Request)错误解决方法
- 解决·微信小程序开发-网络请求报Invalid request 400错误
- asp.net Web Service请求因 HTTP 状态 400 失败: Bad Request的原因
- 微信小程序的ajax数据请求wx.request
- SQL 2005 Report Server 请求因 HTTP 状态 400 失败: Bad Request 处理方法 的解决方法
- 微信小程序request请求实例,网络请求。
- 微信小程序请求网络API 400错误的解决方法
- Spring MVC HTTP 400 错误 - 请求无效 (Bad request)
- 微信小程序入门三request请求
- 微信小程序开发(request请求后台获取不到data)
- 微信小程序:wx.request之post请求后端无法获取数据的问题
- 微信小程序request请求实例,网络请求。
- ERROR 微信安卓报http 400 Bad Request -Invalid Header name错误
- 微信小程序 wx.request 出现 Failed to load resource: the server responded with a status of 400
- 微信小程序request出现400的问题解决办法
- $.ajax请求报400 bad request错误
- 微信小程序request请求封装