I'm trying to add attachment to Jira issue from Matlab. The code below returns HTTP Status 200 OK, but the file is not added to the Jira issue. What is the reason for that?
import matlab.net.http.io.MultipartProviderimport matlab.net.http.io.FileProviderimport matlab.net.http.io.MultipartFormProviderHeaderField = matlab.net.http.HeaderField('Authorization','Basic USERNAME:PASSWORD', 'Content-Type','multipart/form-data', 'X-Atlassian-Token','no-check');fps = FileProvider("myfile.txt");mp = MultipartProvider(fps);formProvider = MultipartFormProvider("files",mp);req = matlab.net.http.RequestMessage('post',HeaderField,formProvider)req.send('https://XXX.atlassian.net/rest/api/2/issue/TEST-1/attachments')
I can add the attachment from windows command prompt using code (as instructed here: Atlassian document):
curl -D- -u USERNAME:PASSWORD -X POST -H "X-Atlassian-Token: no-check" -F "file=@myfile.txt" https://XXX.atlassian.net/rest/api/2/issue/TEST-1/attachments
Best Answer