GraphiQl mutation addTicket error

Hello!
I made a script to import orders from website, but mutation doesn’t work if orders added. When orders[] empty the ticket created with id. Can anyone help to solve it?

mutation m{addTicket(
ticket:{type:“Delivery Ticket”,
department:“Pizzéria”,
user:“Administrator”,
terminal:“Szerver”,
note:"Megj.: szállítási cím: Százhalombatta, Botond u. 11 ",
entities:[{entityType:“Customer”,name:“703333333”}],
states:[
{stateName:“Status”,state:“Unpaid”},
{stateName:“Source”,state:“Site”},
{stateName:“Delivery”,state:“Unconfirmed”}
],
tags:[{tagName:“Delivery Minutes”,tag:“30”}],
calculations:[],
orders:[{
name:“Misc”,
menuItemName:“Pizza Pack 5”,
quantity:1,
price:5900,
tags:[{tagName:“Default”,tag:“Margherita”,price:0,quantity:1},{tagName:“Default”,tag:“Kolbászos”,price:0,quantity:3},{tagName:“Default”,tag:“Palermo”,price:0,quantity:1}],
},{
name:“Misc”,
menuItemName:“Szállítási költség”,
quantity:1,
price:400,
tags:[],
}]
}){id}}

gql response:
{
“data”: {
“addTicket”: null
},
“errors”: [
{
“ClassName”: “GraphQL.ExecutionError”,
“Message”: “Error trying to resolve addTicket.”,
“Data”: null,
“InnerException”: {
“ClassName”: “System.NullReferenceException”,
“Message”: “Object reference not set to an instance of an object.”,
“Data”: null,
“InnerException”: null,
“HelpURL”: null,
“StackTraceString”: " at Samba.Services.Graphql.Builders.GraphTicketBuilder.AddOrders(Ticket ticket, List1 orders, TicketType ticketType, User user, Department department, Terminal terminal) in C:\\Users\\vehbi\\Source\\Repos\\sambapos-v5-pro\\Samba.Services\\Graphql\\Builders\\GraphTicketBuilder.cs:line 104\r\n at Samba.Services.Graphql.Builders.GraphTicketBuilder.CreateTicketFromTicketInput(TicketInput ticketInput) in C:\\Users\\vehbi\\Source\\Repos\\sambapos-v5-pro\\Samba.Services\\Graphql\\Builders\\GraphTicketBuilder.cs:line 41\r\n at Samba.Services.Graphql.Tickets.TicketMutation.AddTicket(ResolveFieldContext context) in C:\\Users\\vehbi\\Source\\Repos\\sambapos-v5-pro\\Samba.Services\\Graphql\\Tickets\\TicketMutation.cs:line 826\r\n at GraphQL.DocumentExecuter.<ResolveFieldAsync>d__8.MoveNext()", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": "8\nAddOrders\nSamba.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\nSamba.Services.Graphql.Builders.GraphTicketBuilder\nVoid AddOrders(Samba.Domain.Models.Tickets.Ticket, System.Collections.Generic.List1[Samba.Services.Graphql.Tickets.OrderInput], Samba.Domain.Models.Tickets.TicketType, Samba.Domain.Models.Users.User, Samba.Domain.Models.Tickets.Department, Samba.Domain.Models.Settings.Terminal)",
“HResult”: -2147467261,
“Source”: “Samba.Services”,
“WatsonBuckets”: null
},
“HelpURL”: null,
“StackTraceString”: null,
“RemoteStackTraceString”: null,
“RemoteStackIndex”: 0,
“ExceptionMethod”: null,
“HResult”: -2146233088,
“Source”: null,
“WatsonBuckets”: null
}
]
}

Is it just me or are you not missing quotes on allot of the json?
I was always under impression you should quote both parts of each value unless integer or null.
If you look at the response both sides are quoted…
Not saying that’s you issue but should get all correct before testing deeper.

1 Like

Also couple of stay commas, although dont think an unneserserry ending comma would be major issue in itself in theory it isnt needed/shouldnt be there.

Not fluent in graphql so not sure is the ticket should be part of function or json but if its part of json missing the opening {

Thanks for reply!
I think everything fine with commas and quotes, the problem is with order items, but I don’t know what.
ticket created without order items:

mutation m{addTicket(
ticket:{type:“Delivery Ticket”,
department:“Pizzéria”,
user:“Administrator”,
terminal:“Szerver”,
note:"Megj.: Utánvétes fizetés Százhalombatta, Botond u. 11 szállítási cím: Százhalombatta, Botond u. 11 ",
entities:[{entityType:“Customer”,name:“703333333”}],
states:[
{stateName:“Status”,state:“Unpaid”},
{stateName:“Source”,state:“Woocommerce”},
{stateName:“Delivery”,state:“Unconfirmed”}
],
tags:[{tagName:“Delivery Minutes”,tag:“30”}],
calculations:[],
orders:[]
}){id}}

response:
{
“data”: {
“addTicket”: {
“id”: 2110
}
},
“errors”: null
}

Well its invalid json in theory but fine, if you want to disregard that then so be it. I dont know but perhaps the issue has been caught in some parts but orders section hasnt got an exception for it.
Other though is are you sure you should be doing in single function of add ticket?
Sure its not add ticket to create ticket then another function to add orders?
As I said am not fluent in graphql without it in front of me cant say fure sure or recall all functions.

I creatad earlier another import script, there is no errors. so I don’t know what’s wrong :frowning:

OK, looking at some requests by jesse;
I cannot see a portion value?
Also do you not want any order states on these orders?

Ok, sorry I find whats wrong :frowning: I don’t created default tag at item. Solved with creating item default tag.

Please show for others that may read this facing similar issues…

Steps:

  1. Settings/Products/Product list/Misc product ->Tag: Default
  2. Settings/Tickets/Order Tags/Add Order tag Group ->Name: Default, set free tagging, set add price to order, add mapping.
    Then restart messaging server. This solved my issue.
1 Like