I have searched everywhere to get an answer for my question. I really need an expert to help me with my problem. I have created code to POST data using ajax to an external api url.
The code I create is like below :
$.ajax({
url: "https://www.billplz.com/api/v3/collections",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + "73eb57f0-7d4e-42b9-a544-aeac6e4b0f81:");
},
type: "POST",
data: {
"title": "My First API Collection"
},
contentType: 'application/json',
dataType: 'jsonp',
success: function(data) {
alert("Successfully Registered..");
},
error: function(xhRequest, ErrorText, thrownError) {
alert("Failed to process correctly, please try again");
console.log(xhRequest);
}
});
I tried to get this sample curl code from API doc :
# Creates an open collection
curl https://www.billplz.com/api/v3/open_collections \
-u 73eb57f0-7d4e-42b9-a544-aeac6e4b0f81: \
-d title="My First API Open Collection" \
-d description="Maecenas eu placerat ante. Fusce ut neque justo, et aliquet enim. In hac habitasse platea dictumst." \
-d amount=299
The API doc is here
I had tried all methods given by the previous problem but no luck. I also tried to do this in JQuery/AJAX without PHP.