Access denied when trying to save file in custom-app

Hello @Thakur_Ganeshsingh ,

The documentation for the “create a ticket with attachment” tells you to attach the file via a path on your machine.

curl -v -u user@yourcompany.com:test -F ‘attachments=@/Users/user/Desktop/api_attach.png’ -F ‘subject=Support Needed…’ -F ‘description=Details about the issue…’ -F ‘email=tom@outerspace.com’ -F ‘priority=1’ -F ‘status=2’ -F ‘workspace_id=3’ -X POST ‘https://domain.freshservice.com/api/v2/tickets

In the meantime I found another way to send files to freshservice, in my case I’m using axios library.

function getFileAndSend(){
    axios.get(`https://imageurl.com`, { responseType: 'arraybuffer' })
    .then(response => {
        let form = new FormData();
        form.append("attachments[]", response.data, {filename: 'file.jpg'});
        form.append("body", "aaaaaaaaaaaaaaaa");

        axios.post("https://helpdesk.freshservice.com/api/v2/tickets/{id}/reply", 
            form, 
            {
                headers: 
                {
                    'Authorization': FRESHAUTH,
                    'Content-Type': form.getHeaders()['content-type']
                }
            }
            )
        .then(res => console.log(res))
        .catch(e => console.error(e.response.data));
    })
    .catch(e => console.log(e));
}

I suggest that someone fixes the documentation so no one gets deceived by it anymore.

Have a good day.

2 Likes