Announcement

Collapse
No announcement yet.

Update Order Status via API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update Order Status via API

    Is there a simple way to update an order status by order id using urlFetchApp?

    The API documentation is written of XMLHttpRequest() but I am using Google Apps Script and need to update via urlFetchApp.
    Last edited by TokenGary; 11-09-2020, 05:51 PM.

  • #2
    Which API are you using Soap or Rest?

    With the rest API if you can run a curl command and PHP from google Apps scripts:


    PHP Code:
    $modauth = array(
    "Content-Type: application/json",
    "Accept: application/json",
    "SecureURL: {storeUrl}",
    "PrivateKey: {private key}",
    "Token: {api token}"
    );

    //
    // Updates 3dcart with New Order Status
    $ch curl_init();
    curl_setopt($chCURLOPT_URL"https://apirest.3dcart.com/3dCartWebAPI/v2/Orders/{orderID}");
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    curl_setopt($chCURLOPT_HEADERFALSE);
    curl_setopt($chCURLOPT_CUSTOMREQUEST"PUT");

    curl_setopt($chCURLOPT_POSTFIELDS"{
    ""OrderStatusID"
    "{orderStatusNumber}",";
    }"
    );

    curl_setopt($chCURLOPT_HTTPHEADER$modauth);
    $response curl_exec($ch);
    curl_close($ch); 

    Comment

    Working...
    X