Discussions
Problem with uploading a new Attachment to job via API
over 2 years ago by UPRAVA-Marcel Golob
Hi, here is my code to upload attachment to my job. But this doesn't do anything. What is from in my request?
const options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic bWFyY2VsLmdvbG9iQHRlcm1vc2hvcC5zaTpQdXA4NjYxMQ=='
},
body: JSON.stringify({
uuid: 'eae79142-af52-446c-b315-1e8eba13846b',
related_object: 'job',
related_object_uuid: 'eae79142-af52-446c-b315-1e8eba13846b',
active: 1,
attachment_name: 'nalog3.pdf',
file_type: '.pdf',
timestamp: '2022-06-07 00:00:00',
attachment_source: 'nalog3.pdf'
})
};
fetch('https://api.servicem8.com/api_1.0/attachment.json', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));