A multipart form-post is an HTTP request sent using an HTML form, submitted with enctype set to "multipart/form-data". The request body is specially formatted as a series of "parts", separated with MIME boundaries. To create tickets in your HappyFox account via API using multipart/form data, please follow the below sample code written in python.
import requests
company_name = <add_your_company_name/Instance_name>
url = "https://" + company_name + ".happyfox.com/api/1.1/json/tickets/"
payload ={
'category': '1',
'user': '2',
'text': 'Testing',
'subject': 'Subject ',
}
files = {'attachments': open('/File Path/file.extension','rb')}
headers ={
'Authorization': '<BASIC auth>',
'Content-Type': 'multipart/form-data; boundary=--------------------------531818130631649698349478'
}
response = requests.request("POST", url, headers=headers, data = payload, files = files)
print(response.text.encode('utf8'))
To get the <BASIC auth> from your HappyFox API credentials, please use the below python library request.
from requests.auth import _basic_auth_str
api_key = <Key>
auth_code = <Code>
BASIC auth = _basic_auth_str(api_key, auth_code)
API Endpoint URL for ticket creation: https://<account_name/instance_name>.happyfox.com/api/1.1/json/tickets/
Method: POST
content-type: multipart/form-data
Alternatively, for code snippets in other programming languages, Postman can be used. Please refer to this article - https://learning.postman.com/docs/sending-requests/generate-code-snippets/