cancel
Showing results for 
Search instead for 
Did you mean: 

API Create Order - Correct Store ID

SamQSM
New Contributor

Hey all,

I'm looking for some help/insight into an issue I'm having importing orders to the correct manual store.

Background:

My company has set up manual stores per client within Shipstation. The clients place their orders on a google sheet and we import from there. Our current process is all manual. My goal is to automate those uploads via Script & API.

Solution:
I have successfully built the script to upload to Store A (Our first manual store), however when I put the script into a different client's sheet and change the storeId variable, it still uploads to Store A.

I've added Logs to ensure the storeId variable is carried across the script correctly as well as logs to break down the payload being sent as a new order, however when i reach this part:

(var response = UrlFetchApp.fetch("https://ssapi.shipstation.com/orders/createorder", options);
    Logger.log("New order created. Response:");
    Logger.log(response.getContentText());
 
The log produces the previous storeid.
 
Here is the existing function I have in place to create the order:
 
function createShipStationOrder(payload, storeID) {
    payload.storeId = storeID; // Set the storeId property of the payload
    Logger.log("Creating new order with payload:");
    Logger.log(payload); // Log payload details
    var options = {
        method: "post",
        headers: {
            "Authorization": "Basic " + Utilities.base64Encode(apiKey + ":" + apiSecret),
            "Content-Type": "application/json"
        },
        payload: JSON.stringify(payload)
    };
    var response = UrlFetchApp.fetch("https://ssapi.shipstation.com/orders/createorder", options);
    Logger.log("New order created. Response:");
    Logger.log(response.getContentText());
 
Thanks in advance.
 
tldr: I need to troubleshoot why my storeId isn't being updated during the communication between my google script and Shipstation.

 

1 REPLY 1

SamQSM
New Contributor

Follow-up on this.

I needed to add the storeId to the AdvancedOptions section of my payload. It didn't automatically reassign the value.