Curl -u equivalent in HTTP request

2019-02-21 17:50发布

I've been trying to plug into the Toggl API for a project, and their examples are all using CURL. I'm trying to use the C# wrapper which causes a bad request when trying to create a report, so I thought I'd use Postman to try a simple HTTP request.

I can't seem to get the HTTP request to accept my API Token though. Here's the example that they give (CURL):

curl -u my-secret-toggl-api-token:api_token -X GET "https://www.toggl.com/reports/api/v2/project/?page=1&user_agent=devteam@example.com&workspace_id=1&project_id=2"

I've tried the following HTTP request with Postman with a header called api_token with my token as the value:

https://www.toggl.com/reports/api/v2/project/?user_agent=MYEMAIL@EMAIL.COM&project_id=9001&workspace_id=9001

(changed ids and email of course).

Any help on how to use the CURL -u in HTTP would be appreciated, thanks.

标签: http curl
1条回答
够拽才男人
2楼-- · 2019-02-21 18:32

The easy way is adding credential into url as user:pass@ format.

https://my-secret-toggl-api-token:api_token@www.toggl.com/reports/api/v2/project/?page=...
        <---------------------------------->

Alternately you can use credential with your http header like below:

Authorization: Basic XXXXXX

Here XXXXXX is base64(my-secret-toggl-api-token:api_token)

查看更多
登录 后发表回答