Skip to main content

[PHP] New ticket with attachment


Hello,

This is starting to get on my nerves now... I've got a PHP script that submits tickets but fails when attachments are added. Can anybody spot anything that's wrong?


The error I get is:

jSON response:Array
(
    [description] => Validation failed
    [errors] => Array
        (
            [0] => Array
                (
                    [field] => custom_fields
                    [message] => Value set is of type String.It should be a/an key/value pair
                    [code] => datatype_mismatch
                )
        )
)


And then the curl options look like this:

cURL options:Array
(
    [42] => 1
    [10002] => https://apogeecorp.freshdesk.com/api/v2/tickets
    [10005] => ####:####
    [19913] => 1
    [81] => 
    [64] => 1
    [74] => 
    [91] => 
    [10018] => Apogee Corp
    [47] => 1
    [10036] => POST
    [10015] => Array
        (
            [name] => Marius Cucuruz
            [email] => mcucuruz@apogeecorp.com
            [subject] => TEST: new IT ticket via API (with attach)
            [description] => new IT ticket via API with PDF attachment
            [source] => 1
            [priority] => 1
            [status] => 2
            [type] => IT
            [group_id] => 6000198310
            [custom_fields] => Array
                (
                    [flag] => 
                    [cause] => Support Request
                    [type_it] => IT Request
                )
            [attachments[]] => CURLFile Object
                (
                    [name] => /var/www/intranet/wp-content/uploads/2018/04/1524152398.pdf
                    [mime] => application/pdf
                    [postname] => 1524152398.pdf
                )
        )
)

If needed I can provide the PHP script too, though I reckon it's something I'm missing in the above. The request is done via POST and no headers are set with it.


What could it possibly be? I swear it was working a week ago...


Any help is greatly appreciated. Thanks in advance.



Cheers

Did this topic help you find an answer to your question?
This topic has been closed for comments