VaRest
VaRest copied to clipboard
POST/JSON setting form data on request.
I can't seem to get VaRest to submit a JSON request that my Django service can use. I'm able to access my service with a handful of other scripts, programs, javascript, for example. I'm trying to send a list of IDs to pull data for.
So here's a Python script and results from postman - it works exactly as it should:
If the image is readable, you can see that the IDs are present in both the "form" field, and the "json" fields. Apparently, the web service has no problem with the data being in the form field.
Using this snippet:
![Screenshot 2020-12-14 222324](https://user-images.githubusercontent.com/36518551/102167538-999c4200-3e5c-11eb-9fda-f127cb9f4c88.png)
What I get from postman is this:
LogVaRest: Response (200): JSON( {"args":{},"data":{"ids":["937050.3","937051.3","939929.3"]},"files":{},"form":{},"headers":{"x-forwarded-proto":"http","x-forwarded-port":"80","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5fd82bc8-746a7fe4651b023b16206052","content-length":"63","accept":"/","accept-encoding":"deflate, gzip","cookie":"sails.sid=s%3A3tUpyCJCPiBis5YOEQRh_ItmsTLbKL9M.6 ZMhy90vV1b07BXLSc3hIBcJsp%2F5dVskqELySZ3LUGM","content-type":"application/json","user-agent":"redacted"},"json":{"ids":["937050.3","937051.3","939929.3"]},"url":"http://postman-echo.com/post"} )JSON
So the data is there - in the "data" field, but not the "form" field.
OK, before we move along here - I see the content-type is different (json vs x-www-form-urlencoded), but when I set VaRest to either of the form encodings (URL or Body), neither one shows any "data" or "json" at all.
When I use url-encoded(URL) I get this:
{"args":{},"data":"","files":{},"form":{},"headers":{"x-forwarded-proto":"http","x-forwarded-port":"80","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5fd8301c-3eb8d66a16c2400374569401","content-length":"0","accept":"/","accept-encoding":"deflate, gzip","cookie":"sails.sid=s%3AZ7JqgpiIfCmLrfPoqGKsuQu4L_tfGLFl.FURNerLHTOHlq3vJDEaSxeFwQlEHipKnrDjbvQ1yfX 8","content-type":"application/x-www-form-urlencoded","user-agent":"redacted"},"json":null,"url":"http://postman-echo.com/post"} )JSON
And url-encoded(Body):
{"args":{},"data":"","files":{},"form":{},"headers":{"x-forwarded-proto":"http","x-forwarded-port":"80","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5fd83094-3f8fac9f64c8bfd64fc3d4ed","content-length":"0","accept":"/","accept-encoding":"deflate, gzip","cookie":"sails.sid=s%3AAPhnJyvd_tfVuQAN2Ikxai8RQKGXwmaj.PY1nFvglk8BWaj8t0GLbbj4R%2Bo1JmXE9LNJTzWwx mAU","content-type":"application/x-www-form-urlencoded","user-agent":"redacted"},"json":null,"url":"http://postman-echo.com/post"}
I know that this will work with other services, but help getting those IDs into the form field would be really appreciated.
Currently it's not supported, but I'll take a look
@ufna is it possible to have content type as multipart/form-data i want to do something similar Pass audio file and data .
I am doing something like this, request is sent with the audio file but the server does not have the right content type
@ufna can you give me a hint as to how i can send a multi-part form data as content type and additional key value pair as binary file.
@fredjh were you able to update the VAREST plugin to send a file and json data?