Archived Forum Post

Index of archived forum posts

Question:

.NET HTTP post content not sent

Oct 10 '16 at 09:16

Hello , I`m having a problem , I have this PHP code :

 if (!isset($_POST["license"])) {
    die("no license"); // it will allways halt here
} else {
    $heads["license"] = $_POST["license"];
}

And the following .NET code :

Dim http As New Chilkat.Http
'removed unlock
Dim req2 As New Chilkat.HttpRequest
req2.Path = "/api/v1/?get=lib&format=json"
req2.AddHeader("swid", "1")
req2.AddHeader("swver", "1.2")
req2.AddHeader("ukey", "49918b558f5367c313d5d500fb24f6447b33dc5873b6d34c7d5844cb74d63896")
req2.AddParam("license", "license here") ' error here ?
req2.HttpVerb = "POST"

Dim resp As New Chilkat.HttpResponse
resp = http.SynchronousRequest("localhost", 80, False, req2)
If (resp Is Nothing) Then
    Console.WriteLine(http.LastErrorText)
    Exit Sub
Else
    Console.WriteLine(resp.BodyStr)
End If
Console.ReadLine()

What am I doing wrong ? I receive all the headers but not the POST content. Thanks in advance !


Answer

AddParam will add text to the url. You might be looking for AddStringForUpload, or one of the other "Add*ForUpload" methods.