I'm trying to replicate the following curl command in PowerShell:
linguist@qa:~ % curl -X POST -F text="Example lesson text" -F share_status=private \
-F title="Example Lesson Ttiel" -F collection=50510 \
-F image=@/home/lingq/Pictures/penguin.jpg \
-F tags=British -F tags=European
'https://www.lingq.com/api/languages/en/lessons/' -H 'Authorization: Token bd894eabcd4c0'
This is an API usage example from their page, I'm working with the assumption that it works. I don't know if it actually does, I don't have curl, and I don't want to have curl if possible. I've been trying to recreate the command in PowerShell using the InvokeRestMethod function. So far what I got is this:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization","Token db3403c339fb4515c2940cccdcdcdbdcdbdcdbddc4cf453534453")
$response = Invoke-RestMethod -Method Post 'https://www.lingq.com/api/languages/ja/lessons/' -Headers $headers
I'm not even sure I'm adding the header with the token correctly, and I have no idea how to add the parameters that follow the -F in curl. I don't need image and tags, but the rest are crucial. Any ideas?
Edit: I have verified that the authentication token header works, by calling
Invoke-RestMethod -Method Get 'https://www.lingq.com/api/profile/' -Headers $headers
with my token and getting my profile. I've also found out what the ominous -F means in curl, it's form data. So now I'm trying to figure out how to send 4 form data values in one Invoke-RestMethod call.