Hi,
I’m trying to create a shop menu using the Graphql Admin API, one day ago was working totally fine but for some reason today I get this “Internal error. Looks like something went wrong on our end.” error. The code is written in PowerShell. I will provide an example of what I am doing.
I tried with library “2024-10” and “2024-07” but with same output from both.
The graphql mutation is extracted directly from the documentation here
$library = "2024-10"
function Invoke-GraphQL($query, $vars) {
$uri = "https://" + $basestoreURL + "admin/api/" + $library + "/graphql.json"
$headers = @{
"X-Shopify-Access-Token" = $ControlPanelApiToken
"Content-Type" = "application/json"
}
if ($vars) {
$body = @{
query = $query
variables = $vars
} | ConvertTo-Json -Depth 10 -Compress
}
else
{
$body = @{
query = $query
} | ConvertTo-Json -Depth 10 -Compress
}
$results = Invoke-WebRequest -Method POST -Uri $uri -Header $headers -Body $body -UseBasicParsing
return $results
}
function New-ShopMenu($menu) {
$query = '
mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}'
$result = Invoke-GraphQL $query $menu
}
$sidebarMenu = @{
title = "Todas las categorías"
handle = "sidebar-menu"
items = @()
}
$sidebarMenu.items += @{
title = "Todos los productos"
url = "/collections/todos-los-productos"
type = "COLLECTION"
resourceId = ...
}
// ... More appends here //
New-ShopMenu $sidebarMenu
The purpose of doing it this way is because the huge amount of collections and menus we need to create.
Thanks.