I’m looking to do a custom POST to create a new doc on my doctype “Reservation”
I’m currently receiving error 400 on this post
var body =
{
'site' : siteName,
'date' : date,
'start': start,
'end' : end
}
this.postData(url, body);
my postData function:
postData(url, body){
return $.ajax({
url: url,
type: 'POST',
data: body,
success: function(data){
console.log(data);
},
error:function(errorThrown){
console.log(errorThrown);
}
});
}
And those four parameters are the only ones that the doctype contains.
The ‘site’ is a link to a document. I’m passing a string of the Name of the document.
The ‘date’ is a date fieldtype. I have tried to pass it as a string and a date object. Still code 400 on each.
The ‘start’ and ‘end’ are time fields. I’m passing strings like so: ‘08:00’ or ‘20:00’
Here is the reservation.json for the doctype:
"actions": [],
"allow_rename": 1,
"autoname": "R.#####",
"creation": "2022-07-25 14:00:51.083468",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"site",
"date",
"start",
"end"
],
"fields": [
{
"fieldname": "date",
"fieldtype": "Date",
"in_list_view": 1,
"label": "Date",
"reqd": 1
},
{
"fieldname": "site",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Site",
"options": "Reservation Site",
"reqd": 1
},
{
"fieldname": "start",
"fieldtype": "Time",
"label": "Start",
"reqd": 1
},
{
"fieldname": "end",
"fieldtype": "Time",
"label": "End",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-08-02 23:43:00.471191",
"modified_by": "Administrator",
"module": "Reservations",
"name": "Reservation",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Reservations User",
"share": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}```