-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GET requests with body params? #729
Comments
The https://github.com/httprb/http/blob/main/lib/http/client.rb#L176-L190 Can you provide a complete reproduction of the issue? |
This curl returns 200 response with expected data: curl --location --request GET 'https://amplitude.com/api/2/taxonomy/event-property' \
--header 'Authorization: Basic MzcwNWMyNGVmMWY5OGMxM2Y3OGY4OTNmN2ZiNDQ5NjI6ZTIwNGMxMjA2ZTc2NDhkZDJjMTI5YjMwM2NlMGQ0OWE=' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'event_type=area_view' I tried this: HTTP.basic_auth(user: "3705c24ef1f98c13f78f893f7fb44962", pass: "e204c1206e7648dd2c129b303ce0d49a")
.get("https://amplitude.com/api/2/taxonomy/event_property", form: { event_type: "area_view" })
.status
# => 404 I tried this: HTTP.basic_auth(user: "3705c24ef1f98c13f78f893f7fb44962", pass: "e204c1206e7648dd2c129b303ce0d49a")
.get("https://amplitude.com/api/2/taxonomy/event_property", body: "event_type=area_view")
.status
# => <html><title>404: Not Found</title><body>404: Not Found</body></html> I finally managed to get it to work with this: HTTP.headers("Authorization" => "Basic MzcwNWMyNGVmMWY5OGMxM2Y3OGY4OTNmN2ZiNDQ5NjI6ZTIwNGMxMjA2ZTc2NDhkZDJjMTI5YjMwM2NlMGQ0OWE=")
.headers("Content-Type" => "application/x-www-form-urlencoded")
.get("https://amplitude.com/api/2/taxonomy/event-property", form: { event_type: "area_view" }).status
# => 200 Feel free to use credentials used here. I made a test project so there is on hard hitting that url with those credentials. I will remove it after this gets resolved. |
HTTP.basic_auth(user: "3705c24ef1f98c13f78f893f7fb44962", pass: "e204c1206e7648dd2c129b303ce0d49a") Generates same headers as: HTTP.headers("Authorization" => "Basic MzcwNWMyNGVmMWY5OGMxM2Y3OGY4OTNmN2ZiNDQ5NjI6ZTIwNGMxMjA2ZTc2NDhkZDJjMTI5YjMwM2NlMGQ0OWE=") Thus, I'm a bit confused with what could be wrong. Can you try verbose logging? HTTP.use(logging: { logger: Logger.new($stderr) })
.basic_auth(...) |
I am dealing with API which requites that all params to GET requests is passed as body.
I could not figure out how to make such a request with httprb.
.get("my url to api endpoint", body: "event_type=#{event_name}"
does not work.Is there something I am not seeing or it is just not supported right now?
I know GET with params is not the best practice but standard supports it and it is third party API so can't change that 😢
The text was updated successfully, but these errors were encountered: