How to initialise nested key value pair

I am using the API connector to call one of ShipStation’s resources and want to initialise an API call without the dynamic parameters/variables initially so I am using Parameters

My question is, if you see an example response with a nested parameter , what do you put in the value field (bit in the red box in the image below)?

In the example in the API doc use

        "billTo": {
        "name": "The President",
        "company": null,
        "street1": null,
        "street2": null,
        "street3": null,
        "city": null,
        "state": null,
        "postalCode": null,
        "country": null,
        "phone": null,
        "residential": null
      }

If the billTo parameter isn’t a required parameter for the API to return a valid response you could check “optional” and it’ll be ignored if the value is empty

At the moment it’s set to required and the value is empty so it will fail


Josh @ Support Dept
Helping no-code founders get unstuck fast :rocket:save hours, & ship faster with an expert :man_technologist: on-demand

I post daily about no-code and Bubble on Twitter Follow Support Dept on Twitter

It actually is a required parameter. That’s the thing

You need to set the json you want in the field, or better, encode the JSON into the parameters. If you have an array of object, you need to use format as text and create the json into the action.
If you can share a link to the API doc, it will be easier to help you

Hmmm so the API is just going to bounce back an error code unless you populate that parameter with a value. There’s no magic to get around that.

Why can’t you put a value in there to initialise the call?


Josh @ Support Dept
Helping no-code founders get unstuck fast :rocket:save hours, & ship faster with an expert :man_technologist: on-demand

I post daily about no-code and Bubble on Twitter Follow Support Dept on Twitter

1 Like

Thanks,

I actually did share the link to the API doc in the original post. It’s here Create/Update Order | ShipStation

I tried using <>in the body parameters. But that didn’t work. I get a 400 status code,

Bad Request - The request could not be understood or was missing required parameters.

The billTo is nested

I have created a Loom video to show my current approach "Issue initialising a nested parameter in Shipstation - 400 status code"

I see what you are doing wrong in your video with the JSON
You are changing the key into a parameters, but you need to change the value
Like
"state":"<state>"
And preserve the JSON structure.

Exemple:

{
  "orderNumber": "<order_number>",
  "orderKey": "<order_key>",
  "orderDate": "<order_date>",
  "paymentDate": "2015-06-29T08:46:27.0000000",
  "shipByDate": "2015-07-05T00:00:00.0000000",
  "orderStatus": "awaiting_shipment",
  "customerId": 37701499,
  "customerUsername": "[email protected]",
  "customerEmail": "[email protected]",
  "billTo": {
    "name": "The President",
    "company": null,
    "street1": null,
    "street2": null,
    "street3": null,
    "city": null,
    "state": null,
    "postalCode": null,
    "country": null,
    "phone": null,
    "residential": null
  },
  "shipTo": {
    "name": "The President",
    "company": "US Govt",
    "street1": "1600 Pennsylvania Ave",
    "street2": "Oval Office",
    "street3": null,
    "city": "Washington",
    "state": "DC",
    "postalCode": "20500",
    "country": "US",
    "phone": "555-555-5555",
    "residential": true
  },
  "items": [
    {
      "lineItemKey": "vd08-MSLbtx",
      "sku": "ABC123",
      "name": "Test item #1",
      "imageUrl": null,
      "weight": {
        "value": 24,
        "units": "ounces"
      },
      "quantity": 2,
      "unitPrice": 99.99,
      "taxAmount": 2.5,
      "shippingAmount": 5,
      "warehouseLocation": "Aisle 1, Bin 7",
      "options": [
        {
          "name": "Size",
          "value": "Large"
        }
      ],
      "productId": 123456,
      "fulfillmentSku": null,
      "adjustment": false,
      "upc": "32-65-98"
    },
    {
      "lineItemKey": null,
      "sku": "DISCOUNT CODE",
      "name": "10% OFF",
      "imageUrl": null,
      "weight": {
        "value": 0,
        "units": "ounces"
      },
      "quantity": 1,
      "unitPrice": -20.55,
      "taxAmount": null,
      "shippingAmount": null,
      "warehouseLocation": null,
      "options": [],
      "productId": 123456,
      "fulfillmentSku": "SKU-Discount",
      "adjustment": true,
      "upc": null
    }
  ],
  "amountPaid": 218.73,
  "taxAmount": 5,
  "shippingAmount": 10,
  "customerNotes": "Please ship as soon as possible!",
  "internalNotes": "Customer called and would like to upgrade shipping",
  "gift": true,
  "giftMessage": "Thank you!",
  "paymentMethod": "Credit Card",
  "requestedShippingService": "Priority Mail",
  "carrierCode": "fedex",
  "serviceCode": "fedex_2day",
  "packageCode": "package",
  "confirmation": "delivery",
  "shipDate": "2015-07-02",
  "weight": {
    "value": 25,
    "units": "ounces"
  },
  "dimensions": {
    "units": "inches",
    "length": 7,
    "width": 5,
    "height": 6
  },
  "insuranceOptions": {
    "provider": "carrier",
    "insureShipment": true,
    "insuredValue": 200
  },
  "internationalOptions": {
    "contents": null,
    "customsItems": null
  },
  "advancedOptions": {
    "warehouseId": 98765,
    "nonMachinable": false,
    "saturdayDelivery": false,
    "containsAlcohol": false,
    "mergedOrSplit": false,
    "mergedIds": [],
    "parentId": null,
    "storeId": 12345,
    "customField1": "Custom data that you can add to an order. See Custom Field #2 & #3 for more info!",
    "customField2": "Per UI settings, this information can appear on some carrier's shipping labels. See link below",
    "customField3": "https://help.shipstation.com/hc/en-us/articles/206639957",
    "source": "Webstore",
    "billToParty": null,
    "billToAccount": null,
    "billToPostalCode": null,
    "billToCountryCode": null
  },
  "tagIds": [
    53974
  ]
}

So I started again,copied and paste the example request from https://shipstation.com/docs/api/orders/create-update-order/… and ran it

billTo can’t be empty, which is why I was asking in my original post that to put in the red box?

Did you set header with content type?

Yeah I have

Put the header directly in the call, not in shared
Can you share your whole settings now?

Incidentally I was also trying this and based on your recommendations above below is my current setting.


I tried this in postman too and the error “400 bad request” followed.

1 Like

starting to think there’s an issue with Shipstations example request, and it’s missing some parameters or something…

1 Like

tried that too, didn’t work either

This is what I think too. I’m testing on my side to check what happen. But if you get the same error in postman… there’s probably an issue in Shipstations!

I am also starting to think there is probably an issue in the sample json body from shipstation.

Try to “GET” the order informations.
Check the payload. In most case, this will be very similar to what you need to send

I can make it work.
Try to start from scratch. Sometimes, call get corrupted, mostly when header are modified.

And here’s the payload used for testing:

{
	"orderNumber": "TEST-ORDER-API-DOCS",
	"orderKey": "0f6bec18-3e89-4881-83aa-f392d84f4c74",
	"orderDate": "2015-06-29T08:46:27.0000000",
	"paymentDate": "2015-06-29T08:46:27.0000000",
	"shipByDate": "2015-07-05T00:00:00.0000000",
	"orderStatus": "awaiting_shipment",
	"customerId": 37701499,
	"customerUsername": "[email protected]",
	"customerEmail": "[email protected]",
	"billTo": {
		"name": "The President",
		"company": null,
		"street1": null,
		"street2": null,
		"street3": null,
		"city": null,
		"state": null,
		"postalCode": null,
		"country": null,
		"phone": null,
		"residential": null
	},
	"shipTo": {
		"name": "The President",
		"company": "US Govt",
		"street1": "1600 Pennsylvania Ave",
		"street2": "Oval Office",
		"street3": null,
		"city": "Washington",
		"state": "DC",
		"postalCode": "20500",
		"country": "US",
		"phone": "555-555-5555",
		"residential": true
	},
	"items": [{
		"lineItemKey": "vd08-MSLbtx",
		"sku": "ABC123",
		"name": "Test item #1",
		"imageUrl": null,
		"weight": {
			"value": 24,
			"units": "ounces"
		}
	}],
	"tagIds": [
		53974
	]
}
2 Likes