Comments (3)
The body:
should be sent regardless of the HTTP method used:
https://github.com/httprb/http/blob/main/lib/http/client.rb#L176-L190
Can you provide a complete reproduction of the issue?
from http.
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.
from http.
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(...)
from http.
Related Issues (20)
- Unable to log or instrument redirects HOT 1
- Using WebSocket URIs without ports raises a NoMethodError
- Do we have support for OAuth1.0 and OAuth2.0 like POSTMAN Tool? HOT 1
- HTTP::ConnectionError on HTTPS queries through HTTP proxies HOT 9
- Upgrade to 5.0.2 potentially caused hanging threads HOT 27
- Cookies extraction is not working properly in 5.x HOT 3
- undefined method 'wait_readable' for #<OpenSSL::SSL::SSLSocket:0x00007feb9ebacc00> HOT 5
- Breaking change not marked as breaking in changelog HOT 2
- Funny behavior of readpartial in JRuby when reading a slow stream
- Found a possible security concern HOT 5
- strange response body HOT 7
- Cannot install gem on an Apple Silicon (M1) Mac HOT 2
- Some sites don't work? HOT 11
- Unknown MIME type: text/plain HOT 4
- Should responses with content-type application/json have UTF-8 encoding by default? HOT 7
- Persistent clients don't support changing headers HOT 3
- Random OpenSSL / Headers parsing error HOT 13
- Requests to an IPv6 address result in: HTTP::ConnectionError (failed to connect: getaddrinfo: Name or service not known) HOT 13
- Incorrect method documentation? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.