Sample code for 30+ languages & platforms
DataFlex

MercadoLibre - Get Recent Orders

See more MercadoLibre Examples

Demonstrates how to get recent orders in Mercadolibre.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Handle hoJsonToken
    String sResponseStr
    String sTemp1
    Boolean bTemp1

    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

    // First get our previously obtained OAuth2 access token.
    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/mercadolibre.json" To iSuccess
    If (iSuccess = False) Begin
        Showln "Failed to load JSON access token."
        Procedure_Return
    End

    // This adds the "Authorization: Bearer $ACCESS_TOKEN" header field.
    Get ComStringOf Of hoJsonToken "access_token" To sTemp1
    Set ComAuthToken Of hoHttp To sTemp1

    // Use your seller ID.
    Get ComSetUrlVar Of hoHttp "SELLER_ID" "577815702" To iSuccess

    // Notice that the query parameter name is "seller".   In other Mercadolibre API calls the query parameter name is "seller_id".
    // Make sure to pay close attention to the Mercadolibre documentation.
    // For example, here:  https://developers.mercadolibre.com.ar/es_ar/gestiona-ventas#Ordenes-recientes
    // and here:  https://developers.mercadolibre.com.ar/en_us/manage-questions-and-answers
    Get ComQuickGetStr Of hoHttp "https://api.mercadolibre.com/orders/search/recent?seller={$SELLER_ID}&offset=0&sort=date_desc&limit=50" To sResponseStr
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln sResponseStr


End_Procedure