简体   繁体   English

使用主体表单数据的nativescript发布请求

[英]nativescript post request using body form-data

I want to send a user JSON object to a login post url like in the screenshot from postman . 我想将用户JSON对象发送到登录帖子网址,如postman的屏幕截图中所示。 to have a successful login it must be exactly as in the screenshot, otherwise I receive user object not found in the response from the api . 要成功登录,必须与屏幕截图中的完全相同,否则我会收到api响应中未找到的用户对象。 So I did not succeed to send a valid user object as the requirement . 因此,我没有成功发送有效的用户对象作为要求。

I get successful login only with postman . 我只有邮递员才能成功登录。 I need a solution for nativescript (typescript) 我需要本机脚本(打字稿)的解决方案

postman screenshot 邮递员屏幕截图

multipart/form-data is not yet supported by Http module. Http模块尚不支持multipart/form-data There is an open feature request that you might want to follow up for updates. 您可能需要跟进一个开放功能请求以进行更新。

Also using form data for passing simple values is not very much encouraged, if you have access to the APIs then I would suggest you to modify them to use JSON. 也不太鼓励使用表单数据来传递简单值,如果可以访问API,那么我建议您修改它们以使用JSON。

I believe nativescript-background-http plugin should work with this scenario, but haven't tried it myself. 我相信nativescript-background-http插件应该可以在这种情况下使用,但是我自己还没有尝试过。 There is also a simple plugin from community that you might want to try. 还有一个来自社区的简单插件 ,您可能想尝试一下。

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

相关问题 是否可以在 POST 请求正文中发送 Json 数据和图像作为表单数据 - Is it possible to send Json Data in the POST request body and an image as form-data 如何使用 FORM-DATA 或 x-www-form-urlencoded 与 Android 进行发布请求? - How to do a post request using FORM-DATA or x-www-form-urlencoded with Android? 邮递员在尝试使用表单数据执行 POST 时返回 415,但与 JSON 相同的请求工作正常 - Postman returns 415 when trying to do a POST using form-data, but the same request with JSON works fine 将json post请求更改为multipart / form-data - Change a json post request to multipart/form-data 帖子中的文件请求有效内容为空,表单数据的文件名为空 - Empty file request payload on post and empty filename for form-data 使用 axios 在 POST 多部分/表单数据请求中发送文件和 json - sending file and json in POST multipart/form-data request with axios 使用Volley在body中发布form-data参数 - Posting form-data Parameters in the body using Volley 如何使用凌空传递URL的正文标签的表单数据 - How to pass form-data of body tag of URL using volley 如何使用带有表单数据主体而不是json主体的http'POST'? (Angular2 /打字稿) - How to use http 'POST' with form-data body instead of json body? (Angular2/Typescript) 在 multipart/form-data 选项的帮助下使用 python 发布数据 - post data using python with help of multipart/form-data option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM