如何在网页上使用Rest

时间:2019-03-22 09:39:55

标签: json rest

如何与网页上的Rest api通信? 我有这个脚本,但是无法正常工作。

<script>
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://my.site/api/incidents/', true);
xhr.setRequestHeader('Authorization', 'Basic codexxxx');
xhr.setRequestHeader('Content-Type', ' application/json');
xhr.send('{"callerLookup" :{"email":"kundens@email.dk"},"status":"firstline","request":"Test.","category": {"name": "Kundeservice"},"operatorGroup":{"id": "76127b-17ba-4f81-84b5- dab10f6b4254","name":"Kundeservice"},"callType":{"id":"61f98687-dae3-5e5c-a611- b82db2877036"},"impact" : {"id": "587628-b1f5-542c-b120-64ced89815","name": "Person"},"priority":{"id": "e5355405-1795-4543-963d- 897c0b6ea37"},"briefDescription" : "Test","entryType":{"id": "8dee51b4-8445- 5d04-b507-fb5faa47ad7","name":"Selvbetjeningsportal"}}');
</script>

1 个答案:

答案 0 :(得分:0)

对不起,脚本正在运行。验证码不正确。