POST data to API


Hi, Been trying to post some data to an API located here

I think I have the code right as I am not getting any errors and the console logs look ok (not that I know for sure) but the data is not getting posted Could someone look over the code and log to see if I am missing something obvious, API’s are new to me so I could be missing something. Thanks for looking.


<meta charset="UTF-8"> 
<title> Ajax and Json | Tutorial</title>

<form method=post>
<div class="ajax-container">
	<input type="button" id="btnAjaxCall" value="Ajax Call" />
	<div class="display-data">


<script src="" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
var count = 0;

function fetchDataAndDisplay(){
		headers: { 
					//'content-type': 'application/x-www-form-urlencoded',
					//'Access-Control-Allow-Origin': '*',
					//'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE',
					//'Access-Control-Allow-Headers': 'Content-Type, Authorization',
					//'content-type': 'application/json; charset=UTF-8'
					//"apiKey": "123456789101112131415167"

		dataType: 'json',

		data: {


"authentication": {
    "apiKey": "123456789101112131415167"
"createProperties": [
        "name": "New Hotel 1",
        "propKey": "YourKeyToUseForTheNewHotel1",
        "notifyUrl": "http:\/\/\/api\/newbookings",
        "roomTypes": [
                "name": "Room 1",
                "qty": "1",
                "minPrice": "0.00"
                "name": "Room 2",
                "qty": "3",
                "minPrice": "0.00"
        "name": "New Property 2",
        "propKey": "YourKeyToUseForThepropIdNewProperty2",
        "notifyUrl": "http:\/\/\/api\/index.php?action=updatebooking",
        "roomTypes": [
                "name": "Camp Site",
                "qty": "10",
                "minPrice": "0.00"
                "name": "Cabin",
                "qty": "2",
                "minPrice": "0.00"


Console response:

Request URL:
Request Method: POST
Status Code: 200 OK
Remote Address:
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Length: 56
Content-Type: application/json
Date: Sat, 15 Sep 2018 09:48:29 GMT
Keep-Alive: timeout=5, max=100
Server: Apache
Provisional headers are shown
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: http://localhost:8081
Referer: http://localhost:8081/sample5/getajax_bed24v2.html
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
authentication[apiKey]: 123456789101112131415167
createProperties[0][name]: New Hotel 1
createProperties[0][propKey]: YourKeyToUseForTheNewHotel1
createProperties[0][roomTypes][0][name]: Room 1
createProperties[0][roomTypes][0][qty]: 1
createProperties[0][roomTypes][0][minPrice]: 0.00
createProperties[0][roomTypes][1][name]: Room 2
createProperties[0][roomTypes][1][qty]: 3
createProperties[0][roomTypes][1][minPrice]: 0.00
createProperties[1][name]: New Property 2
createProperties[1][propKey]: YourKeyToUseForThepropIdNewProperty2
createProperties[1][roomTypes][0][name]: Camp Site
createProperties[1][roomTypes][0][qty]: 10
createProperties[1][roomTypes][0][minPrice]: 0.00
createProperties[1][roomTypes][1][name]: Cabin
createProperties[1][roomTypes][1][qty]: 2
createProperties[1][roomTypes][1][minPrice]: 0.00


The data being returned to you indicates the server received the data correctly.
Verify your API keys, and contact the API host to inquire as to why it isn’t processing.