Problem with Variable in Array

Hello everyone, I have a workflow and I am receiving this Array, but I cannot extract the license_key data to continue my flow.

[{"license_id":"70","item_id":40,"product_id":15,"variation_id":0,"license_key":"0029651675700852","max_instance_number":"0","visible":"Yes","uses":0,"expiration_date":"0000-00-00"}]

The idea would be to just get the license key. To get the line of code with you through {{ $('Webhook').item.json.body.meta_data[2].value}}

Information on your n8n setup

  • n8n version: 1.34.2
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: Own
  • Running n8n Docker
  • Operating system: Linux

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @Kaue_camelo

you can use the Edit Fields node, set the name as you want, type: Object, value: {{ $json.body.meta_data[2].value }}. Then you will be able to retrieve the license_key from it

Hello barn4k, I tried here, but the node returned an error

Ah… please, change Object to Array type

Hello, I made the adjustment but the output still comes out empty



Just ignore it and leave empty

Seems you need to clear the execution (trash bin icon) and run it again.
image

The same, it comes out empty again

Can you share the workflow and the output of the Webhook?

[
{
"headers": 
{
"host": 
"test.test.com",
"user-agent": 
"WooCommerce/8.6.1 Hookshot (WordPress/6.5)",
"content-length": 
"2408",
"accept": 
"*/*",
"accept-encoding": 
"deflate, gzip",
"content-type": 
"application/json",
"x-forwarded-for": 
"198.168.0.1",
"x-forwarded-host": 
"test.test.com",
"x-forwarded-port": 
"443",
"x-forwarded-proto": 
"https",
"x-forwarded-server": 
"5ef1ee0e2b0d",
"x-real-ip": 
"198.168.0.1",
"x-wc-webhook-delivery-id": 
"7d8e500c813e0af7d023e9eed78f68dd",
"x-wc-webhook-event": 
"updated",
"x-wc-webhook-id": 
"1",
"x-wc-webhook-resource": 
"order",
"x-wc-webhook-signature": 
"au9ZiDdzTMGbTjIQJYKjCgGXI1LF7wZP8T9oYtcaqok=",
"x-wc-webhook-source": 
"https://test.com/",
"x-wc-webhook-topic": 
"order.updated"
},
"params": 
{
},
"query": 
{
},
"body": 
{
"id": 
271,
"parent_id": 
0,
"status": 
"completed",
"currency": 
"BRL",
"version": 
"8.6.1",
"prices_include_tax": 
false,
"date_created": 
"2024-04-08T17:27:29",
"date_modified": 
"2024-04-08T18:07:32",
"discount_total": 
"0.00",
"discount_tax": 
"0.00",
"shipping_total": 
"0.00",
"shipping_tax": 
"0.00",
"cart_tax": 
"0.00",
"total": 
"23.00",
"total_tax": 
"0.00",
"customer_id": 
0,
"order_key": 
"wc_order_qZ3ElqNxD4j6D",
"billing": 
{
"first_name": 
"Kaue",
"last_name": 
"Test",
"company": 
"",
"address_1": 
"",
"address_2": 
"",
"city": 
"",
"state": 
"",
"postcode": 
"",
"country": 
"BR",
"email": 
"[email protected]",
"phone": 
"+15575451874"
},
"shipping": 
{
"first_name": 
"",
"last_name": 
"",
"company": 
"",
"address_1": 
"",
"address_2": 
"",
"city": 
"",
"state": 
"",
"postcode": 
"",
"country": 
"",
"phone": 
""
},
"payment_method": 
"woo-mercado-pago-pix",
"payment_method_title": 
"Pix",
"transaction_id": 
"",
"customer_ip_address": 
"",
"customer_user_agent": 
"",
"created_via": 
"admin",
"customer_note": 
"",
"date_completed": 
"2024-04-08T17:28:51",
"date_paid": 
"2024-04-08T17:28:51",
"cart_hash": 
"",
"number": 
"271",
"meta_data": 
[
{
"id": 
3069,
"key": 
"_wc_order_attribution_source_type",
"value": 
"admin"
},
{
"id": 
3080,
"key": 
"fslm_licensed",
"value": 
"true"
},
{
"id": 
3081,
"key": 
"fslm_json_license_details",
"value": 
"[{"license_id":"70","item_id":40,"product_id":15,"variation_id":0,"license_key":"0029651675700852","max_instance_number":"0","visible":"Yes","uses":0,"expiration_date":"0000-00-00"}]"
}
],
"line_items": 
[
{
"id": 
40,
"name": 
"Test (30D)",
"product_id": 
15,
"variation_id": 
0,
"quantity": 
1,
"tax_class": 
"",
"subtotal": 
"23.00",
"subtotal_tax": 
"0.00",
"total": 
"23.00",
"total_tax": 
"0.00",
"taxes": 
[
],
"meta_data": 
[
],
"sku": 
"",
"price": 
23,
"image": 
{
"id": 
"103",
"src": 
"https://test.com/wp-content/uploads/2024.png"
},
"parent_name": 
null
}
],
"tax_lines": 
[
],
"shipping_lines": 
[
],
"fee_lines": 
[
],
"coupon_lines": 
[
],
"refunds": 
[
],
"payment_url": 
"https://test.com/checkout/order-pay/271/?pay_for_order=true&key=wc_order_qZ3ElqNxD4j6D",
"is_editable": 
false,
"needs_payment": 
false,
"needs_processing": 
true,
"date_created_gmt": 
"2024-04-08T20:27:29",
"date_modified_gmt": 
"2024-04-08T21:07:32",
"date_completed_gmt": 
"2024-04-08T20:28:51",
"date_paid_gmt": 
"2024-04-08T20:28:51",
"currency_symbol": 
"R$",
"_links": 
{
"self": 
[
{
"href": 
"https://test.com/wp-json/wc/v3/orders/271"
}
],
"collection": 
[
{
"href": 
"https://test.com/wp-json/wc/v3/orders"
}
]
}
}
}
]

The problem is not in the last block, in my executions, Edit Fields does not return any value and continues the flow

For me everything works fine

Perfect, in fact the error was in the old data that was running, I launched a new webhook and it started working

Now how do I make the variable to use the license_key? I’m having difficulties.

you can refer to {{ $json.license[0].license_key}} after the Edit Fields node or use the absolute reference {{ $('Edit Fields').item.json.license[0].license_key}}

3 Likes

Thanks for your efforts barn4k, it worked perfectly! Thank you very much, have a great week

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.