I'm creating an extension that automates procedures within Codenvy by using the REST API they provide. However, I'm having trouble with a multipart/form-data POST request. Specically, creating a new factory.
This is my ajax/jquery call:
$.ajax({
type: 'POST',
url: 'https://codenvy.com/api/factory',
data: formData,
processData: false,
contentType: false,
success:function(data) {
callback();
},
error:function(e) {
console.log(e);
}
});
But I get a 409 error with the message:
No factory URL information found in 'factoryURL' section of multipart/form-data
I already posted on Codenvy forums, but the only useful thing I got was a curl command
POST http://domain.com/api/factory?token= $token -H 'Content-Type: multipart/form-data' -F 'factoryUrl={$JSONofFactoryConfig}'
rfc2388 says something about a name field, but I have no idea how to convert the curl name field into an ajax request.
How should I go about adding this "factoryUrl" field to my POST request?
It looks like you are missing factoryUrl in your payload. It should be:
factoryUrl={json_with_project_config}
I resolved this. I knew that I was missing the factoryUrl portion in my payload, I just didn't know how to put it in my payload. The following code does the job.
var formData = newFormData();
formData.append('factoryUrl', JSON.stringify(jsonObject));
// Send ajax post request
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.