ajax请求接口与postman请求接口格式问题

发布时间:2022-06-29 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了ajax请求接口与postman请求接口格式问题脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

(一)ajax post请求接口时,postman可以请求成功(本次传参为Body下raw格式下传的是JSON格式),则前端页面请求不成功,则检查postman

ajax请求接口与postman请求接口格式问题

默认header请求头中 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 , 若后端需要 application/json 则修改请求头header中的 Content-Type: application/json 且数据需要

ajax请求接口与postman请求接口格式问题

则将要传的数据通过JSON.stringify()包裹即可。

(二) 请求格式为这种 Form Data 请求头部的 Content-Type: application/x-www-form-urlencoded,请求正文是类似 get 请求 url 的请求参数 修改

ajax请求接口与postman请求接口格式问题

(三) 请求格式为这种 Request Payload 请求头部的 Content-Type: application/json,请求正文是一个 json 格式的字符串 修改

ajax请求接口与postman请求接口格式问题

脚本宝典总结

以上是脚本宝典为你收集整理的ajax请求接口与postman请求接口格式问题全部内容,希望文章能够帮你解决ajax请求接口与postman请求接口格式问题所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: