0

I am attempting to use the TeamForge API. This is my first dip into web requests so I am sure I am missing something obvious.

To even begin, I realize I need to request an oauth token. According to the documentation, I have to execute the following command:

# Base URL of TeamForge site.
site_url="https://teamforge.example.com"

# TeamForge authentication credentials.
username="foo"
password="bar"

# Requested scope (all)
scope="urn:ctf:services:ctf urn:ctf:services:svn urn:ctf:services:gerrit urn:ctf:services:soap60"

curl -d "grant_type=password&client_id=api-client&scope=$scope&username=$username&password=$password" $site_url/oauth/auth/token

Seems fairly straightforward. Knowing that curl is an alias for Invoke-WebRequest, I attempted to run the following in PowerShell:

$site="https://my.teamforge.site"
$user="myuser"
$pass="mypass"
$scope="urn:ctf:services:ctf"
curl "grant_type=password&client_id=api-client&scope=$scope&username=$user&password=$pass" -Uri $site/oauth/auth/token

What I got was an error:

Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'grant_type=password&client_id=api-client&scope=urn:ctf:services:ctf&username= rest of line redacted for obvious reasons

I took this to mean I fudged the syntax. I have no clue where to start taking this appart and plugging it into Invoke-WebRequest command. Like I said, this is my first time attempting this. My searches for answers thus far has not been helpful. I think I am asking the wrong questions.

How do I deconstruct this curl command so that I can convert it to something I can use in PowerShell?

2
  • Are you trying to use Invoke-WebRequest or are you trying to use curl.exe? curl is (somewhat stupidly) a default alias for Invoke-WebRequest. If you want to call the executable, which is what it looks like here, call curl.exe. Commented Jan 11, 2018 at 21:48
  • Possible duplicate of convert simple curl data request to powershell invoke-webrequest. Commented Jan 12, 2018 at 0:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.