javascript - Ajax Post request formation while calling the api -
i configuring ajax post request hit api.
below curl command (its dummy):
curl -x post \ --header 'content-type: application/json' \ --header 'accept: application/json' \ --header 'authorization: token' \ --header 'timestamp: test' \ --header 'sourcesystemid: test' \ --header 'sourcesystemuserid: test' \ --header 'sourceserverid: test' \ --header 'trackingid: test' \ -d '{"accountid": "123456789","modeofbusiness": "audio"}' \ 'https://services-services.c1.com:443/api/customer/v1/services/querysummary'
need reform hit using ajax request. ajax code this? how pass --header
, -d
tag in this? api returning response in json format. below ajax code.
var accntno = document.getelementbyid('accntnotext').value; var token = document.getelementbyid('tokentext').value; //event.preventdefault(); var queryapi = "https://services-services.c1.com:443/api/customer/v1/services/querysummary"; $.ajax({ url: queryapi, method: 'post', datatype: "json", data: { accountid: accntno, modeofbusiness: "audio"}, headers: { 'authorization': token,'timestamp': 'test', 'sourcesystemid':'test','sourcesystemuserid': 'test', 'sourceserverid':'test','trackingid': 'test','content-type':'application/json'}, success: function (data) { alert(data); } });
for starters:
- your curl has
accountid
, jquery hasaccountnumber
- your http method
post
, notpost
- your jquery headers missing
accept
, has weird whitespace incontent-type
Comments
Post a Comment