Curl -u equivalent in HTTP request

I am trying to connect to the Toggl API for a project, and their examples use CURL. I am trying to use a C # shell that causes a bad request when trying to create a report, so I decided to use Postman for a simple HTTP request.

I cannot force an HTTP request to accept my API token. Here is an example 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 tried the following HTTP request with Postman with a header called api_token with my token as value:

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

(changed identifiers and email, of course).

Any help on using CURL -u in HTTP would be appreciated, thanks.

+9
curl
source share
2 answers

An easy way to add credentials to a URL in the format user: pass@ .

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

Alternatively, you can use the credentials with your HTTP header, as shown below:

 Authorization: Basic XXXXXX 

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

+16
source

As explained to me in another post, you can pass the API token to the user property if you use HttpWebRequest:

 request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes($"my-secret-toggl-api-token:api_token"))); 
0
source

All Articles