Sending JSON payload to API in POST body
See original GitHub issueI have noticed that when I call my endpoints, like so:
import { endpoints } from "wildcard-api/client";
// in some async function
const response = await endpoints.saveNewCronJob({ newCronJob: editingCronJob });
I’m getting a request being sent out that looks like this:
http://localhost:8080/wildcard/saveNewCronJob/%5B%7B%22newCronJob%22%3A%7B%22id%22%3A%22%22%2C%22payloadType%22%3A%22TEXT%22%2C%22payload%22%3A%22%22%2C%22title%22%3A%22%22%2C%22timezone%22%3A%22Etc%2FGMT%22%2C%22endpointType%22%3A%22PUBSUB%22%2C%22endpoint%22%3A%22http%3A%2F%2Flocalhost%3A8080%2Ftest-cron-endpoint%22%2C%22enabled%22%3Afalse%2C%22description%22%3A%22%22%2C%22dateUpdated%22%3A%22json-s%3AtYpE%7CDate%7C2019-03-05T14%3A05%3A14.498Z%22%2C%22dateCreated%22%3A%22json-s%3AtYpE%7CDate%7C2019-03-05T14%3A05%3A14.498Z%22%2C%22crontab%22%3A%220%200%201%2F24%20*%20*%20*%22%7D%7D%5D
This indicates that the JSON is being serialised and set in the request url as a query string. While this is fine for small payloads, when things get large things might not work out too well (https://stackoverflow.com/questions/32763165/node-js-http-get-url-length-limitation).
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
How do I post JSON to a REST API endpoint? - ReqBin
To post JSON to a REST API endpoint, you must send an HTTP POST request to the REST API server and provide JSON...
Read more >How should I pass json data in the request payload of http ...
Most requests the client application (an Electron app) will be sending contains JSON-based bodies, with the only exception being multipart ...
Read more >JSON Payload for POST Request - R-bloggers
Starting with JSON body because this is the way that most API documentation will give you the payload examples. Send the body as...
Read more >Add a Request Body to a POST Request | API Connector
Enter a Request Body As part of a POST , PUT , or PATCH request, a data payload can be sent to the...
Read more >Sending JSON HTTP Request Body in Terminal - Baeldung
HTTP requests for verbs such as POST, PUT, and PATCH optionally sends a request body payload as part of the request.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is nothing to check out 😃 Just update to
v0.7.x
and leave your code as it is. (Or simply keepv0.5.x
.)(I didn’t forget about this. I’m on vacation. Ttyl.)