Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(e) {
- var jsonStr = {
- "ContactName": "smith, anthony",
- "FirstName": "anthony",
- "LastName": "smith"
- };
- function make_base_auth(user, password) {
- var tok = user + ':' + password;
- var hash = btoa(tok);
- return "Basic " + hash;
- }
- var userName = "admin";
- var password = "admin";
- var authStr = convertStringToBase64(userName + ":" + password);
- var authObj = '{"authentication":authStr}';
- $.ajax({
- url: "http://127.0.0.1:8086/api/services/Customers/RegisterCustomer",
- headers: {
- "Authorization": make_base_auth(userName, password)
- },
- beforeSend: function(xhr) {
- xhr.setRequestHeader("Content-Type", "application/json");
- xhr.setRequestHeader("Accept", "application/json");
- //xhr.setRequestHeader ("Authorization", make_base_auth (userName, password));
- },
- crossDomain: true,
- type: "POST",
- dataType: "json",
- data: JSON.stringify(jsonStr),
- success: function(result, status, jqXHR) {
- $("preerror").text("IT WORKED");
- var jsonStr = result;
- var jsonObj = JSON.parse(jsonStr);
- var jsonPretty = JSON.stringify(jsonObj, null, 't');
- $("pre").text(jsonPretty);
- },
- error(jqXHR, textStatus, errorThrown) {
- $("pre").text("FAIL");
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement