在HTTP请求中卷曲-u等效 [英] Curl -u equivalent in HTTP request

查看:187
本文介绍了在HTTP请求中卷曲-u等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为项目插入Toggl API,他们的示例都使用了CURL。我正在尝试使用C#包装器,在尝试创建报告时会导致错误请求,所以我想我会使用Postman尝试一个简单的HTTP请求。

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.

我似乎无法获得接受我的API令牌的HTTP请求。以下是他们给出的示例(CURL):

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"

我已经使用Postman尝试了以下HTTP请求,其标头名为
api_token,我的令牌为值:

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

(当然更改了ID和电子邮件)。

(changed ids and email of course).

任何有关如何在HTTP中使用CURL -u的帮助都将不胜感激,谢谢。

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

推荐答案

简单的方法是将凭证添加到URL中 user:pass @ format。

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=...
        <---------------------------------->

或者,您可以将凭证与http头一起使用,如下所示:

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

Authorization: Basic XXXXXX

此处 XXXXXX base64(my-secret-toggl-api-token:api_token)

这篇关于在HTTP请求中卷曲-u等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆