简体   繁体   English

POST请求在POSTMAN中有效,但在我的代码JS中无效

[英]POST request works in POSTMAN but not in my code JS

I tried my post request in POSTMAN everything working fine. 我在POSTMAN中尝试了发帖请求,一切正常。 When I pasted the code as Ajax or XRH from POSTMAN, I've got an error message : 当我从POSTMAN中将代码粘贴为Ajax或XRH时,出现了错误消息:

 -  net::ERR_ABORTED 405 (Method Not Allowed) from chrome or firefox

I am working as localhost from home : can it be a privileges access issue and I don't have enough rights to POST as localhost ? 我正在在家中以localhost的身份工作:这是否是特权访问问题,而我没有足够的权限以localhost身份进行POST?

here is my post request : 这是我的要求:

  var data = new FormData(); data.append("file", file); data.append("backup_date", date); data.append("backed_up_device_name", device); var settings = { "async": true, "crossDomain": true, "url": "url", "method": "POST", "dataType": "jsonp", "headers": { "Content-Type": "application/x-www-form-urlencoded", "cache-control": "no-cache", }, "processData": false, "contentType": false, "mimeType": "multipart/form-data", "data": data } $.ajax(settings).done(function (response) { console.log(response); }); 

Thanks for your answers 谢谢你的回答

The server MUST generate an Allow header field in a 405 response containing a list of the target resource's currently supported methods. 服务器必须在405响应中生成允许标头字段,其中包含目标资源当前支持的方法的列表。

For further information, see the doc 有关更多信息,请参阅文档

That is to say, the POST request to url is not acceptable by your server. 也就是说,您的服务器不接受对url的POST请求。 Try looking at this carefully: 尝试仔细看一下:

"url": "url", // what is the url? `"url":"ServerURL"`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 POST请求在Postman中有效但在js代码中给出了Bad Request - POST request works in Postman but gives Bad Request in js code 发布请求在 Postman 和 Insomnia 中工作正常,但在 JS 代码中不能正常工作 - Post request works fine in Postman and Insomnia, but not in JS code Axios 发布请求 React.js 时出现网络错误,但适用于 Postman - Axios Network error on post request React.js but works on Postman HTTP 发布请求适用于 Postman 但不适用于 VS 代码 - HTTP post request that works in Postman but does not work in VS code 发布请求在 Postman 中有效,但在 Javascript 中无效 - Post Request Works in Postman But Not in Javascript Http 请求在 PostMan 中有效,但在 JS 中无效 - Http request works in PostMan but not in JS 我的 GET 请求在 POSTMAN 和 Curl 中运行良好,但在 JavaScript 代码中运行良好 - My GET request works fine in POSTMAN and Curl, but not in JavaScript code 代码中我的对话流请求有什么问题(它适用于邮递员)? - What is the problem of my dialogflow request in the code (it works with postman)? 邮递员能够发送POST请求,但不能发送我的前端代码 - Postman able to send POST request but not my frontend code 邮递员邮寄请求有效,但 ajax 邮寄无效。 一遍又一遍地检查客户端js - Postman post request works but ajax post does not. Have checked client side js over and over
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM