rollbar-gem icon indicating copy to clipboard operation
rollbar-gem copied to clipboard

Show request.body of GET request

Open ksdputra opened this issue 2 years ago • 3 comments

Hey,

Is there a way to show request.body for GET requests unless put the params in extra? Have read the documentation, googling, and even ask chatGPT, but no luck. Maybe I didn't pay too much attention, but please guide me.

ksdputra avatar Mar 16 '23 13:03 ksdputra

GET requests don't have a body, per the HTTP spec. Maybe you are looking for request.params?

brianr avatar Mar 16 '23 16:03 brianr

I believe it's request.body.

In postman, it looked like this: Screenshot 2023-03-20 at 08 44 21

The curl is:

curl --location --request GET 'localhost:3300/partner/check-status' \
--header 'Content-Type: application/json' \
--data '{
	"mto_name": "mastercard",
	"external_id": "93618bea-9cb7-42f1-b379-87e75fa67d63"
}'

I know this is not the best practice, but I am working on legacy code.

So, is there a built-in way to put the request.body of GET request to the payload other than putting in extra?

As an integration engineer who integrates with more than 30 companies, I found many companies that put request.body in GET request. I agree it's not the best practice, but many people still do it.

ksdputra avatar Mar 20 '23 00:03 ksdputra

Huh, TIL!

So you want the request body to appear in the Rollbar UI when an error occurs during a GET request - is that correct?

The relevant part of the rollbar-gem code is: https://github.com/rollbar/rollbar-gem/blob/master/lib/rollbar/request_data_extractor.rb#L31-L64

brianr avatar Mar 20 '23 04:03 brianr