Skip to content
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

Adds content type headers for curl tests in docs #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JGantner
Copy link

@JGantner JGantner commented Jan 7, 2025

While doing the exercise i realized that the curl tests for the first stage did not work on my machine. I got an 415 HTTP error specifying that the provided media type is not correct. Since we're sending json data we should also specify the content type of the sent data. For details of the output se below:

julie@Gsiminurok MINGW64 /g/dev/learning-rust/api-axum (main)
$ curl --request POST   --url http://localhost:8000/question   --header 'Accept: application/json'   --data '{
        "title": "Title",
        "description": "Description"
}' --verbose
Note: Unnecessary use of -X or --request, POST is already inferred.
* Host localhost:8000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8000...
*   Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000
* using HTTP/1.x
> POST /question HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.11.0
> Accept: application/json
> Content-Length: 52
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 52 bytes
< HTTP/1.1 415 Unsupported Media Type
< content-type: text/plain; charset=utf-8
< content-length: 54
< date: Tue, 07 Jan 2025 15:51:15 GMT
<
Expected request with `Content-Type: application/json`* Connection #0 to host localhost left intact

Updated the test commands to include the media type to fix the issue.
For context i used the curl available in my git-bash on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant