{"action":"closed","issue":{"url":"https://api.github.com/repos/Accela-Inc/developer-forum/issues/74","labels_url":"https://api.github.com/repos/Accela-Inc/developer-forum/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/Accela-Inc/developer-forum/issues/74/comments","events_url":"https://api.github.com/repos/Accela-Inc/developer-forum/issues/74/events","html_url":"https://github.com/Accela-Inc/developer-forum/issues/74","id":92182589,"number":74,"title":"Example of doing a POST with construct","user":{"login":"TonyCat","id":3309771,"avatar_url":"https://avatars.githubusercontent.com/u/3309771?v=3","gravatar_id":"","url":"https://api.github.com/users/TonyCat","html_url":"https://github.com/TonyCat","followers_url":"https://api.github.com/users/TonyCat/followers","following_url":"https://api.github.com/users/TonyCat/following{/other_user}","gists_url":"https://api.github.com/users/TonyCat/gists{/gist_id}","starred_url":"https://api.github.com/users/TonyCat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TonyCat/subscriptions","organizations_url":"https://api.github.com/users/TonyCat/orgs","repos_url":"https://api.github.com/users/TonyCat/repos","events_url":"https://api.github.com/users/TonyCat/events{/privacy}","received_events_url":"https://api.github.com/users/TonyCat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-30T19:47:03Z","updated_at":"2015-07-13T20:09:01Z","closed_at":"2015-07-13T20:09:01Z","body":"I can get information from the construct APIs but I'm unable to post anything. I keep getting a Bad Server error. The documentation online never really shows what is needed to do a post. Am I missing a header? I just want to verify that I can post using any API I figured contacts would be easy since there are no required fields.\r\n\r\nxhr.open(\"POST\", \"https://apis.accela.com/v4/contacts\");\r\n\t/// I think this is all the request headers I need????\r\n\txhr.setRequestHeader(\"Accept\",\"application/json\");\r\n\txhr.setRequestHeader(\"Authorization\", mytoken); ///I pass in the token via a variable this is not the issue it works on get requests that require tokens\r\n\txhr.setRequestHeader(\"x-accela-appid\",myAppidNumber);\r\n\txhr.setRequestHeader(\"x-accela-appsecret\",myAppSecret);\r\n\txhr.setRequestHeader(\"x-accela-environment\",\"DEV\");\r\n\txhr.setRequestHeader(\"x-accela-agency\",myAgency);\r\n\txhr.setRequestHeader(\"Content-Type\",\"application/x-www-form-urlencoded\");\r\n\txhr.setRequestHeader(\"Cache-Control\",\"no-cache\");\r\n\r\n\r\n\t \r\n\t\r\n\tvar testbody = {\"email\":\"Tony@yahoo.com\",\"individualOrOrganization\":\"individual\",\"phone1\":\"5188675309\",\"firstName\":\"TONY\",\"lastName\":\"DCAT\"};\r\n\r\n\txhr.send(JSON.stringify(testbody)); \r\n///Does the body need to be stringified?? I tried with & without\r\n\r\n\txhr.onload = function() {\r\n\t\tTi.API.info('RAW =' + this.responseText);\r\n\t\tif (this.status == '200') {\r\n\t\t\tTi.API.info('got my response, http status code ' + this.status);\r\n\t\t\tif (this.readyState == 4) {\r\n\t\t\t\tvar response = JSON.parse(this.responseText);\r\n\t\t\t\tTi.API.info('Response = ' + response);\r\n\t\t\t} else {\r\n\t\t\t\talert('HTTP Ready State != 4');\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\talert('HTTp Error Response Status Code = ' + this.status);\r\n\t\t\tTi.API.error(\"Error =>\" + this.response);\r\n\t\t}\r\n\r\n\t}; \r\n\r\n"}}