I am attempting to use the JSON API to create tickets with file attachments. Creating tickets with the API works perfectly when there are no attachments, but as soon as I add the attachments field I get an 500 error in response. After digging through some logs, I found the following error in our PHP error log:
thrown in C:\inetpub\wwwroot\osticket\include\class.forms.php on line 5369
[17-Apr-2024 17:19:42 UTC] PHP Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, array given in C:\inetpub\wwwroot\osticket\include\class.forms.php:5369
Stack trace:
#0 C:\inetpub\wwwroot\osticket\include\class.forms.php(5369): explode()
#1 C:\inetpub\wwwroot\osticket\include\class.forms.php(4367): FileUploadWidget->getValue()
#2 C:\inetpub\wwwroot\osticket\include\class.forms.php(1385): Widget->parseValue()
#3 C:\inetpub\wwwroot\osticket\include\class.forms.php(686): FormField->getWidget()
#4 C:\inetpub\wwwroot\osticket\include\class.dynamic_forms.php(1356): FormField->getClean()
#5 C:\inetpub\wwwroot\osticket\include\class.dynamic_forms.php(1316): DynamicFormEntry->saveAnswers()
#6 C:\inetpub\wwwroot\osticket\include\class.ticket.php(4392): DynamicFormEntry->save()
#7 C:\inetpub\wwwroot\osticket\include\api.tickets.php(142): Ticket::create()
#8 C:\inetpub\wwwroot\osticket\include\api.tickets.php(117): TicketApiController->createTicket()
#9 C:\inetpub\wwwroot\osticket\include\class.dispatcher.php(153): TicketApiController->create()
#10 C:\inetpub\wwwroot\osticket\include\class.dispatcher.php(40): UrlMatcher->dispatch()
#11 C:\inetpub\wwwroot\osticket\api\http.php(29): Dispatcher->resolve()
#12 {main}
thrown in C:\inetpub\wwwroot\osticket\include\class.forms.php on line 5369
A sample attachments key/value pair I'm adding looks like this:
"attachments":[{"filename.txt":"data:text/plain;charset=utf-8,This is the content of the attachment"}]
I've seen a couple other forum posts about this for older versions but have not been able to find an adequate solution, any suggestions? Thanks.