Back to All

Error 400 creating a form

function prueba(){
var headers = {
'Authorization': 'Basic ****'
};
var payload = {
'name': 'prueba1',
'templateId': '**',
'assignment': {
'id': '****',
'type': "User"
},
'fields': {}
}

  var params = {
    'contentType': 'application/json; charset=utf-8',
    "headers": headers,
    "method": 'post',
    "payload": payload
}
var url = 'https://api.goformz.com:443/v2/formz'; 
var response = UrlFetchApp.fetch(url, params);
var responseCode = response.getResponseCode();

}

*** ERROR 400 ****
"code": 400,
"status": "Bad Request",
"message": "Invalid Model",
"errors": null,
"requestUrl": "https://api.goformz.com/v2/formz"...

If I use the following model in "Version 2 of the GoFormz Rest API" web page, it works fine, but it doesn't work in google apps scripts.

{
'name': 'prueba1',
'templateId': '**',
'assignment': {
'id': '****',
'type': "User"
},
'fields': {}
}