[Help needed] HTTP module — Sending multiple bundles in a JSON payload as 1 iterative collection?

hey Make peeps :wave:

Seeking help! hopefully someone in the community can point me in the right direction :crossed_fingers:
(also like to preface that I’ve searched / tried extensively for a solution, but can’t get this particular scenario to work. Also, my ‘technical’ know-how is pretty low (still learning!))

The goal:
Get (watch) Etsy shop receipts, and then using the receipt data, push a HTTP request to Holded API to generate sales receipts in Holded

(the current Holded module doesn’t have the ‘create document’ action available by defuault, hence why I’ve opted for the HTTP/API route)

The sales receipt in Holded should contain all transaction items that are in the Etsy order, which leads me to my obstacle

The issue
Most orders have more than 1 item, but when building out the API payload in the HTTP module and sending test requests, I can’t get multiple bundles to be sent as 1 operation (1 sales receipt document).

Instead, I have 2 operations as the output, which generates 2 separate documents in Holded for each Etsy transaction collection (product), rather than 1 operation/document with multiple transaction collections (products) iterated over.

Along with this, I also need to send another fixed ‘item’ to Holded for shipping price too, but the shipping data doesn’t exist in the same array / collection data in the initial data source schema.

So, I assumed that this would have to be sent as a fixed item, and then a secondary item that iterates between the product transactions list.

Steps I’ve taken

  1. After the Etsy module (Watch Shop Receipts), I’ve added an iterator to split the Etsy ‘Transactions array’ into bundles.

  2. Then, in my payload I have a second item for pulling in the product transactions data.
    screenshot below

:question:so, how do I go about iterating over bundles to item(s) in the request payload?
If not this method, what set of modules are recommended to use in my scenario?

Any guidance would be very much appreciated, thanks! :pray:

Hi @aidy

you can use the add() function to add the collection to your array of items. See screenshots below. Hope this helps.

Cheers,
Gijs

2 Likes

I can only upload 5 images per post. So here is the last 3.

2 Likes

@ecomsilio
Amazing! Implementing this now — a huge thanks for the help!

Thanks Thank You GIF by Sound FX

Do you have a course, or any 3rd party resources you’d recommend for handling more advanced make scenarios?

Cheers!

1 Like

Hi @aidy

I got all my knowledge from Alex Chekalov.
https://automate.smartsol.ca/make-for-makers-order

Cheers
Gijs

2 Likes

Thx again for the help @ecomsilio !

The add function solved my issue with getting the items array and the shipping collection together. :ok_hand:

However, my obstacle now is transforming the collections from the original transactions array (Etsy) into the correct items array structure, so I can then use it with the add function you had shown.

In your example, the items array is already set in the correct format for the iterator — that’s my goal.

Steps I’ve done

  • Parse JSON to create the shipping collection (data structure = collection)

  • Then, I added an iterator to separate the Etsy transactions array into collections (# variable depending on the amount of Etsy products purchased)

  • After this, I have an aggregate to JSON module with the data structure set to Array > Collection.

But, the output isn’t what I need :confused:

Instead of one array ‘items’ with x# of collections within it… I get two separate arrays, or collections (also tried with a collection data structure)

image

I also experimented with the parse JSON module and toArray function, to no avail…

Now, after spending waaaay too much time (≈30hrs) on this task (reading docs, watching YT videos, tweaking the scenario, rinse/repeat), I’m ready to jump on a call and/or hand it over to an expert for a fix — the former would be preferred so I can ask Qs while the solution is being built, but either would be fine at this point :sweat_smile:

I have already generated a dev & testing scenario with dummy data (based on the same Etsy receipt schema), and a custom webhook for the HTTP request with the supported payload for the target platform (Holded) — so this blueprint will be available to work from.

Blueprint: Etsy_to_Holded_receipt.json (77.9 KB)

@ecomsilio lmk if you’re available to take on this on and your proposed rate via PM.
Ideally, I’d like to have this sorted today/tomorrow :pray:

Thanks!
Aidy

Hi @aidy

It happened to me before. Meanwhile I know, that when I get stuck, I let it rest for a day and get back to it the next day. It doesn’t happen to often anymore due to more and more experience but when it happened in the past, this pause of a day usually made me think different about it and often solved the issue within minutes.

I think the problem is in your data structure. Give me a call at +49 30 577 017 10 tomorrow between 9:30 h and 11:00 h or between 12:00 h and 14:00 h CEST or let me know when you have some time. We can do an online meeting via zoom or any other service you prefer. If we get it fix in 10 min. (I expect we do) it is on the house.

Cheers,
Gijs

1 Like

Hey @ecomsilio

Thanks for the encouraging perspective! :raised_hands:

The diminishing returns are hitting my morale hard, I’ll take another swing and see how it goes :muscle:

Really appreciate your kindness!

As you advised above — I’ll come at it again with fresh eyes/mind tomorrow.

If I end up with the same outcome, then I’ll take you up on your offer :ok_hand:

Cheers,
Aidy

2 Likes

@ecomsilio I finally got it working! :grin: :raised_hands:
(the odds were a bit stacked against me today too… had to create a new US1 account to work on it)

So, the solution in the end was quite simple.

I created a new aggregate JSON module after the iterator that gets the transactions from the Etsy array. Data structure set as collection that replicates the properties needed for the HTTP payload.

Then, created a set variable module with a substring function to remove the enclosing [ ] that Make appends to iterator bundles.

Code
{{substring(JSON String; 1; length(JSON String) - 1)}}
Code referenced from this topic

After that, it was a case of creating the correct JSON format in the HTTP module’s payload for this variable + the shipping item, hit run, and boom!:boom:Invoice created! Great success!

I then decided to remove the set variable module and just add the substring function directly into the HTTP content payload (no need to expense +1 operation when it’s not required)


The format ain’t pretty, but it works

I’ll experiment with another parse JSON and/or the existing aggregate JSON structure to see if I can output the shipping item and then transform it into the correct format to be added to the items array in the HTTP payload.

Thanks again @ecomsilio for the help & encouragement! :metal: Much appreciated :man_bowing:t2:

2 Likes