GET with body sends as query string
See original GitHub issueI have the following contract for a consumer. The request works when sending it to the server using Postman.
When the pact provider tries to verify it fails. The body is sent in the query string and not in the body of the GET request as expected.
Using the latest version of PactNet.
{
"consumer": {
"name": "Source System"
},
"provider": {
"name": "Event API"
},
"interactions": [
{
"description": "A GET request with event filters",
"providerState": "default state",
"request": {
"method": "get",
"path": "/events",
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"filters": [
{
"type": "state",
"source": "logs"
},
{
"type": "information",
"source": "memory"
}
]
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"data": [
{
"id": 1,
"event": "init",
},
{
"id": 2,
"event": "start",
}
]
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "2.0.0"
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
HTTP GET with request body
Yes, you can send a request body with GET but it should not have any meaning. If you give it meaning by parsing...
Read more >HTTP GET with Request Body A Technical Deep Dive
HTTP GET with request body is a technique that allows you to send data in the body of the request, rather than in...
Read more >Why an HTTP Get Request Shouldn't Have a Body
In this tutorial, we'll learn why an HTTP GET request shouldn't be sent with a body. First, we'll see why that request is...
Read more >Use Case of HTTP GET Request with a Body
I am maintaining a old . aspx page in which all the data required by the page to show the content is passed...
Read more >Should you send a payload in an HTTP GET request?
This is a perfect use case where the complex JSON query can be passed as a request body in the HTTP GET 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
@Nexith That’s going to be the ruby core doing that. Typically a body in a GET requests is not a good idea, purely because the HTTP 1.1 spec had language to indicate it should not be supported on the server side. I know now the spec has been amended, but still you run into compatibility issues like this one. I’d recommend changing your API to accept query params instead and updating the pact to use query, rather than body.
Should be fixed in 4.x with the move to Rust core instead of Ruby (or at least it’ll be broken in a differnt way 😁 )