This skill should be used when the user asks about "request_format", "response_format", "xml format workato", "json format workato", "multipart form", "form-url-encoded", "parse xml", "build xml", or needs to handle different data formats in a Workato connector.
From workato-connector-sdknpx claudepluginhub grailautomation/claude-plugins --plugin workato-connector-sdkThis skill uses the workspace's default tool permissions.
references/guides__data-formats.mdreferences/guides__data-formats__form-url-encoded.mdreferences/guides__data-formats__json-format.mdreferences/guides__data-formats__request_format_multipart_form.mdreferences/guides__data-formats__xml-format.mdGuide for handling different request and response formats in Workato custom connectors.
Workato connectors support multiple data formats:
JSON is the default format. No special configuration needed:
execute: lambda do |connection, input|
post('/api/records')
.payload(
name: input['name'],
email: input['email']
)
# Automatically sends Content-Type: application/json
end
For OAuth token exchanges and simple form submissions:
execute: lambda do |connection, input|
post('/oauth/token')
.payload(
grant_type: 'authorization_code',
code: input['code'],
redirect_uri: input['redirect_uri']
)
.request_format_www_form_urlencoded
# Sends Content-Type: application/x-www-form-urlencoded
end
For file uploads:
execute: lambda do |connection, input|
post('/api/files')
.payload(
file: input['file_content'],
filename: input['filename'],
description: input['description']
)
.request_format_multipart_form
# Sends Content-Type: multipart/form-data
end
For SOAP and XML-based APIs:
execute: lambda do |connection, input|
post('/api/records')
.payload(
'Record' => {
'@xmlns' => 'http://example.com/schema',
'Name' => input['name'],
'Email' => input['email']
}
)
.request_format_xml
# Sends Content-Type: application/xml
end
Responses are automatically parsed as JSON:
execute: lambda do |connection, input|
response = get('/api/records/123')
# response is already a Hash
{ id: response['id'], name: response['name'] }
end
Parse XML responses:
execute: lambda do |connection, input|
response = get('/api/records/123')
.response_format_xml
# Access XML elements
{
id: response.dig('Record', 'Id'),
name: response.dig('Record', 'Name')
}
end
For binary data or custom parsing:
execute: lambda do |connection, input|
content = get("/api/files/#{input['id']}/download")
.response_format_raw
{ file_content: content }
end
Use hashes with special keys:
payload = {
'Envelope' => {
'@xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
'Body' => {
'CreateRecord' => {
'@xmlns' => 'http://example.com/api',
'Name' => 'Test',
'Items' => {
'Item' => [
{ 'Value' => 'A' },
{ 'Value' => 'B' }
]
}
}
}
}
}
Produces:
<Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<CreateRecord xmlns="http://example.com/api">
<Name>Test</Name>
<Items>
<Item><Value>A</Value></Item>
<Item><Value>B</Value></Item>
</Items>
</CreateRecord>
</Body>
</Envelope>
Prefix attribute keys with @:
{
'Record' => {
'@id' => '123', # Attribute
'@type' => 'contact', # Attribute
'Name' => 'John' # Element
}
}
Produces:
<Record id="123" type="contact">
<Name>John</Name>
</Record>
Define namespaces with @xmlns:
{
'soap:Envelope' => {
'@xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
'@xmlns:api' => 'http://example.com/api',
'soap:Body' => {
'api:GetRecord' => {
'api:Id' => '123'
}
}
}
}
Navigate with dig:
response = get('/api/record')
.response_format_xml
# Access nested elements
name = response.dig('Envelope', 'Body', 'GetRecordResponse', 'Record', 'Name')
# Access attributes
id = response.dig('Envelope', 'Body', 'GetRecordResponse', 'Record', '@id')
# Handle arrays
items = response.dig('Envelope', 'Body', 'GetRecordResponse', 'Items', 'Item')
items = [items] unless items.is_a?(Array) # Ensure array
execute: lambda do |connection, input|
post('/api/upload')
.payload(
file: [
input['file_content'],
'application/octet-stream', # Content type
input['filename'] # Filename
],
metadata: input['metadata'].to_json
)
.request_format_multipart_form
end
execute: lambda do |connection, input|
files = input['files'].map do |file|
['files[]', [file['content'], file['content_type'], file['name']]]
end
post('/api/upload')
.payload(Hash[files])
.request_format_multipart_form
end
Override content type when needed:
execute: lambda do |connection, input|
post('/api/data')
.payload(input['raw_data'])
.headers('Content-Type' => 'text/plain')
end
Different request and response formats:
execute: lambda do |connection, input|
# Send form-encoded, receive JSON
response = post('/oauth/token')
.payload(grant_type: 'client_credentials')
.request_format_www_form_urlencoded
# Response is JSON by default
{ access_token: response['access_token'] }
end
For detailed documentation:
references/guides__data-formats.md - Data formats overviewreferences/guides__data-formats__json-format.md - JSON format detailsreferences/guides__data-formats__xml-format.md - XML format detailsreferences/guides__data-formats__form-url-encoded.md - Form URL-encodedreferences/guides__data-formats__request_format_multipart_form.md - Multipart form uploads