Overview
Creating a case with attachment using the JSON API can be done similarly as with the XML API by changing the formatting according to how the FogBugz JSON API should be used.
Solution
When attaching a file you need to:
- change
Content-Type
tomultipart/form-data
- add a text type parameter:
- containing a JSON with all FogBugz parameters of the case, including cmd and token
- The parameter's name does not matter.
- Only the first text type parameter is processed.
- add a file type parameter containing the path to the file to be attached.
- The parameter's name should start with "File", otherwise, it will not be attached.
- Add one such parameter for each file you would like to attach.
Example using curl:
curl --location --request POST 'https://yoursite.fogbugz.com/f/api/0/jsonapi' \
--header 'Content-Type: multipart/form-data' \
--form 'request={
"cmd":"new",
"token": "yourtoken",
"sTitle": "New case created via JSON API",
"sEvent": "This is the first comment for the case.",
}' \
--form 'File1=@/C:/Folder/Sample.txt'