$FreeUploadServer = Invoke-RestMethod -Uri "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver"
Invoke-RestMethod -Uri "http://rs$FreeUploadServer.rapidshare.com/cgi-bin/rsapi.cgi?sub=upload&login=43533592&password=password&filecontent=C:\libs\test.txt"
I have no clue why that isnt working, its something to do with the filecontent parameter but i have read the entire documentation about the API and i cant figure it out.
Make sure you use the
-Method Postparameter/arg combo on the second Invoke-RestMethod call. Also, take a look at this SO response to a similar question about using CURL. After looking at the question and answer, it appears that RapidShare requires filling in POST form fields. In this case you need to specify the-Bodyparameter. I think you’ll use a PowerShell hashtable where each entry corresponds to a form field name/value pair. Looks like the one field needed is thefilecontentfield. Presumably the value is the file’s contents.Also, when you use POST, you’ll have to convert the
GETquery parameters toPOSTform fields e.g.:If
[IO.File]::ReadAlltext()doesn’t cut it perhaps try[IO.File]::ReadAllBytes()instead.