Add article with attachment in PHP curl


  • Used Zammad version: fresh from git
  • Used Zammad installation source: (source, package, …) deb
  • Operating system: ubuntu 18.04
  • Browser + version: safari (current)

Hello everybody,

I’m trying to create an article with an attachment to a ticket using php and curl. My parameter-array is:

Array ( [ticket_id] => 520 [subject] => Serviceanfrage ohne Anlage [body] => Dies ist mein Kommentar. [type] => email [content_type] => text/html [attachments] => Array ( [0] => Array ( [filename] => file.txt [data] => aGVsbG8gd29ybGQ= [mime-type] => text/plain ) ) )

And after “http_build_query” it looks like this:


For me it looks good, but i get the following error:

{“error”:“undefined method `each_with_index’ for #\u003cActionController::Parameters:0x000055e0551e7018\u003e”}

Any ideas?

Greetings from Germany


I solved it by myself. For everyone interested in the solution:

The problem was the format with http_build_query. I changed the format to json in this way:

curl_setopt($curl, CURLOPT_HTTPHEADER, array(“Content-Type: application/json”));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));

1 Like

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