Skip to content

peJsonTransferStatus - cJsonHttpTransfer

Returns the status of the last JSON HTTP request

Type: Property
Access: Read/Write
Data Type: Integer
Parameters: None

Syntax

Property Integer peJsonTransferStatus
Access Type Syntax
Read Access: Get peJsonTransferStatus to IntegerVariable
Write Access: Set peJsonTransferStatus to IntegerVariable/Value

Description

peJsonTransferStatus returns the status of the last JSON HTTP request.

If your HTTP request method fails and returns the bOk variable as false, you can use this value to determine if why your transfer Failed.

Possible return values are:

Constant Meaning
jtsOk Request succeeded
jtsHttpRequestFailed Http request failed
jtsInvalidContentType Invalid contentType received
jtsNotJson Received data not JSON
jtsError Unspecified error

If a JSON/HTTP request fails, the bOk parameter will be false, the return JSON handle will be 0 and peJsonTransferStatus will contain a status code.

Note that an error is not automatically generated. It is expected that you will want to check the peJsonTransferStatus after your request and handle any failures in your code.

If you wish, you can send LastError to generate an error. Or, you can get TransferErrorDescription to return a description of problem.

Get HttpPostJson of oJsonHttpTransfer sHost sFilePath hoJsonRequest (&bOk) to hoJsonResponse
If (not(bOk)) Begin // if no data came back, probably and error
    Get peJsonTransferStatus of hoHttp to eStatus
    If (eStatus=jtsOk) Begin       
        Send DoNoDataWasReturned
    End
    Else if (eStatus=jtsNotJson) Begin       
        Send DoCustomNotJsonError // if not JSON, do custom error
    End
    Else Begin
        Send LastError of hoHttp // all other errors reported by LastError
    End
End

The jtsHttpRequestFailed Status

If the response was jtsHttpRequestFailed, this indicates that there is something wrong with your HTTP transfer. If you need to determine more detailed information about the HTTP error, you can use LastErrorCode and ResponseStatusCode to get more information about the HTTP transfer failure.

See Also

LastError | TransferErrorDescription