Excel Rest API payouts data
-
Hello
Trying to get a consolidated transaction list for the accountant/auditor.
I’ve pulled all the data from /wp-json/wc/v3/orders but I’m getting error 500 from /wp-json/wc/v3/payments/deposits/Working power query code
let
// Base setup for WooCommerce REST API Orders Endpoint
BaseUrl = "https://website.com/wp-json/wc/v3/orders",
Key = "ck_",
Secret = "cs_",
// Construct authorized API request
// Uses standard Basic Authentication via HTTP headers
AuthHeader = "Basic " & Binary.ToText(Text.ToBinary(Key & ":" & Secret), BinaryEncoding.Base64),
// Send API Request (pulling a batch of up to 100 recent orders)
Source = Json.Document(Web.Contents(BaseUrl, [
Headers=[
Authorization=AuthHeader,
// FIXED: Explicitly force the server to respond with data rather than an HTML page
#"Accept" = "application/json",
// FIXED: Mask Excel's user-agent to prevent security firewalls from blocking it as a bot
#"User-Agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
],
Query=[per_page="100", status="completed,processing"]
])),
// Convert raw JSON list of records into a Power Query Table
TableFromList = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// 1. Dynamically extract every single column name present inside the JSON records
AllColumnNames = List.Distinct(List.Combine(List.Transform(TableFromList[Column1], Record.FieldNames))),
// 2. Expand all columns dynamically using that generated list
ExpandedOrders = Table.ExpandRecordColumn(TableFromList, "Column1", AllColumnNames, AllColumnNames)
in
ExpandedOrdersThanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.