Unhandled error: URIError: URI malformed
at encodeURIComponent (native)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:244:27)
at stringifyObject (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:300:16)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:240:12)
at stringifyArray (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:275:14)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:238:12)
at stringifyObject (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:300:16)
at Object.exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:240:12)
at Request.form (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/request/request.js:989:20)
at Request.init (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/request/request.js:247:10)
The second line of the exception says (native), i'm not sure what it means.
How do i resolve this exception.
my set of code
var httpClient = addon.httpClient({
clientKey: req.session.clientKey,
userKey: req.body.userKey,
appKey: addon.key
});
httpClient.post({
url: '/rest/api/2/issue/' + req.body.issueKey + '/attachments',
headers: {
'X-Atlassian-Token': 'nocheck',
'Content-Type': 'application/json',
'Accept': 'application/json'
},
form: {
file: [
(uploadData), // filedata
{
filename: (filename),
contentType: 'image/png'
}
]
}
}, function(err, callbackRes, body) {
});
var r = request.post('http://service.com/upload', function optionalCallback (err, httpResponse, body) { if (err) { return console.error('upload failed:', err); } console.log('Upload successful! Server responded with:', body); }) var form = r.form() form.append('my_field', 'my_value') form.append('my_buffer', new Buffer([1, 2, 3])) form.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png'))) form.append('remote_file', request('http://google.com/doodle.png'))The form that is created here for upload is through the method form() from the request object r.
var httpClient = addon.httpClient({ clientKey: clientKey, userKey: userKey, appKey: addon.key });
httpClient.post( { url: '/rest/api/2/issue/' + issueKey + '/attachments', headers: { 'X-Atlassian-Token': 'nocheck' }, form: { file: [ attachmentContentString, { filename: filename, contentType: 'text/plain' } ] } }, function(err, res) {
// check err and res
});
Unhandled error: URIError: URI malformed
at encodeURIComponent (native)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:244:27)
at stringifyObject (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:300:16)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:240:12)
at stringifyArray (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:275:14)
at exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:238:12)
at stringifyObject (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:300:16)
at Object.exports.stringify (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/qs/index.js:240:12)
at Request.form (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/request/request.js:989:20)
at Request.init (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/request/request.js:247:10)
at new Request (/home/addteq/onDemand/jira-ondemand-sequence-generator/node_modules/atlassian-connect-express/node_modules/request/request.js:98:8)
i have also raised this as a bug in ecosystem.atlassian.net
I have provided the code and data to reproduce this
Pls take a look at it.