POST /submission/{id} doesn't work, doesn't update type: "control_checkbox" with array value
wzup opened this issue · 2 comments
Your stuff doesn't work. POST request returns success but it not success, nothing updated!
I have such a form field:
123: {
text: "Status",
type: "control_checkbox",
answer: [
"Status 1"
],
prettyFormat: "Status 1"
},
I need to update it with this array ["Status 2", "Status 3", "Status 4"]
How do I do it?
Code:
var request = require("request");
var options = { method: 'POST',
url: 'https://api.jotform.com/submission/12345',
qs: { apikey: '...' },
headers:
{ 'cache-control': 'no-cache',
'content-type': 'application/x-www-form-urlencoded',
apikey: '...',
accept: 'application/json' },
form: { 'submission[123]': '["Status 2", "Status 3", "Status 4"]' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
UPD:
Your API doesn't consider array.
When I pass this array ["Status 2", "Status 3", "Status 4"]
your API for some reason takes only first item of the array. Why?? What do you do with the rest of the items? Why they disappeared?
123: {
text: "Status",
type: "control_checkbox",
answer: [
"Status 2"
],
prettyFormat: "Status 2"
},
Please provide us a working example on HOW TO UPDATE type: "control_checkbox"
WITH ARRAY using your API?
My reply to this wrong answer Answered by Denis on December 20, 2016 at 02:34 AM
from this thread .
I don't know who you are, but you do not look like a developer. Because what you say DOES NOT WORK!
Look at screenshot here.
Screenshot 1.
Postman request.
And the result is this. As you can see it is far from success.
Where are other items? Where are Status 2","Status 3
?
123: {
text: "Status",
type: "control_checkbox",
answer: [
"Status 1"
],
prettyFormat: "Status 1"
},
Case2.
A real life request with nodejs request
library.
Again, as you said comma separated without square brackets
let request_options = {
method: 'POST',
url: 'https://api.jotform.com/submission/' + submission_id,
headers: {
"APIKEY": api_key,
"cache-control": "no-cache",
"accept": "application/json",
},
form: {
"submission[123]": '"Status 1","Status 2","Status 3"', // comma separated without square brackets
}
}
request(request_options, (err, response, body) => {
if(err) {
res.status(500).json({error: err });
}
res.status(200).json({body: body });
})
The result is the same as before, only one item saved:
123: {
text: "Status",
type: "control_checkbox",
answer: [
"Status 1"
],
prettyFormat: "Status 1"
},
Either your JotForm API doesn't work, or you do not know how it works.
Can anybody qualified enough explain how JotForm API works? What is format of data for such an update request? Jotform API documentation is miserable. So as developers' answers as I can see.
I need you to tell me the following
- What are types are (precisely) for key and value pairs?
submission[123]
: '"Status 1", "Status 2", "Status 3"'
- What type is
submission[123]
? - What type is
123
? - What quotes have to be used? Single or double?
"submission[" + 123 + "]": <- int
"submission[" + '123' + "]": <- str
- What type is
'"Status 1", "Status 2", "Status 3"'
? Array? String? - What is the delimiter?
"Status 2", "Status 3"
A comma? A semicolon? anything else?