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

Issue with a CURL command #445

Closed
tebancr opened this issue Feb 21, 2024 · 2 comments
Closed

Issue with a CURL command #445

tebancr opened this issue Feb 21, 2024 · 2 comments

Comments

@tebancr
Copy link

tebancr commented Feb 21, 2024

I have the following CURL command, but when I try to make the request, it gives me an error. And I don't know how to solve it.

Curl:

curl -X 'GET' \
  'xxxxxx' \
  -H 'accept: application/json' \
  -H 'ApiKey: xxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": 5,
  "fechaInicial": "2023-02-01",
  "fechaFinal": "2023-05-01"
}'

Sintaxis:

one2<- httr2::request("xxxxxx") %>%
                req_headers(`accept` = "application/json",
                            `ApiKey`="xxxxx",
                            `Content-Type`= "application/json",
                           )%>%
                req_body_json(
                    list(id = 4, fechaInicial="2023-07-01", fechaFinal="2023-09-01" ) )

cone2 %>% req_perform()

This is the error:

! HTTP 405 Method Not Allowed

Thans

@hadley
Copy link
Member

hadley commented Feb 21, 2024

Does curl on the command line work?

@hadley
Copy link
Member

hadley commented Feb 21, 2024

Oh, if I run httr2::curl_translate() on the curl command that you provide, it makes it obvious what the problems is — you forgot the req_method("GET").

@hadley hadley closed this as completed Feb 21, 2024
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

No branches or pull requests

2 participants