Dear friends I have a weird issue I try to connect to an API and when I try to do the API requests in postman or insomnia everything is okay but when I use the same code on my website or even localhost the leads request doesn't work and tells me that api-version is not defined.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var settings = {
"async": true,
"crossDomain": true,
"url": "https://affiliate-api.tradingcrm.com:4477/token",
"method": "POST",
"data": "{ userName: \"alpt\", password: \"Alpt@12345\" }"
}
$.ajax(settings).done(function (response) {
var settings2 = {
"async": true,
"crossDomain": true,
"url": "https://affiliate-api.tradingcrm.com:4477/accounts/lead",
"method": "POST",
"headers": {
"Authorization": "Bearer " + response.Token,
"Api-Version": "3",
"Content-Type": "application/json"
},
"data": "{firstName:\"test\",lastName:\"test2\",email:\"test@test.test\"}"
}
$.ajax(settings2).done(function (response2) {
console.log(response2.accountId);
});
});
</script>
from api-version is not being sent correctly
No comments:
Post a Comment