Sample code for 30+ languages & platforms
DataFlex

Lightspeed - Delete a Product

See more Lightspeed Examples

Remove an existing product based on the unique identifier

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vResp
    Handle hoResp
    Integer iRespStatusCode
    String sTemp1

    Move False To iSuccess

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Implements the following CURL command:

    // curl -X DELETE https://api.webshopapp.com/en/products/PRODUCT_ID.json \
    //   -u API_KEY:API_SECRET

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    Set ComLogin Of hoHttp To "API_KEY"
    Set ComPassword Of hoHttp To "API_SECRET"

    // Use the correct cluster for your shop.  Here are the choices:
    // eu1 https://api.webshopapp.com/en/
    // us1 https://api.shoplightspeed.com/en/
    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoResp to vResp
    Get ComHttpNoBody Of hoHttp "DELETE" "https://api.webshopapp.com/en/products/PRODUCT_ID.json" vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode <> 204) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComBodyStr Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    Showln "Success."


End_Procedure