post

Top  Previous  Next

This function does a standard HTTP get call on the URL provided optionally with a username and password. The result is passed back into the callback function.

Definition

network.post( url, postData, mimeType, callback, timeout, username, password, headers )

 

Name

Type

Description

url

string

Fully qualified URL. For example HTTP://www.promixis.com

postData

string

Data to post.

mimeType

string

The mime type of the postData.

callback

function

The function to be called with the result.

timeout

number

Timeout for operation in ms

username [optional]

string

Username to use in authentication.

password [optional]

string

Password to use in authentication.

headers

table of strings

Headers to send with request. Each string must be of the form HEADER: Value. For example {"Agent: Girder", "FakeHeader": "FakeValue"}

Callback function signature

function ( success, status, body )

 

Name

Type

Description

success

boolean

Returns true if the HTTP call was successful. Note that this could still mean the status code is not 200 ( = HTTP OK ).

status

number

HTTP Status code. 200 = OK.

body

string

The body of the response.

Example

network.post( "http://www.yoururl.com/form.php", 'name=20&id=100', 'data/urlencoded', function ( success, status, body )

 

 if not success then

         print("Sorry could not connect with server")

         return

 end

 

 if status ~= 200 then

         print("Sorry server returned", status)

         return

 end

 

 print(body)

 

end)

 

Submits the url encoded form data to www.yoururl.com/form.php and prints the returned body.

Related

get

Availability

Lua