I have the below script and I want to add username and password to be able to query confluence:
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
$(function() {
$("#submit").click(function() {
var request = $.ajax({
type: "POST",
data: JSON.stringify(
{"jsonrpc" : "2.0", "method" : "getSpaces", "params" : [], "id": 12345 }
),
//Please change <confluence-url> to the relevant url
url: "rpc/json-rpc/confluenceservice-v2",
async: false,
cache: false,
contentType: "application/json",
success: function() {
//alert("success");
}
});
$("#output").html(JSON.stringify(request));
return false;
});
});
</script>
you have to pass username and password as follows
$.ajax
({
type: "GET",
url: "URL",
dataType: 'json',
async: false,
username: username,
password: password,
data: '{ "comment" }',
success: function (){
alert('Thanks for your comment!');
}
});
I tried this it did not work, I'm trying to use basic http authorization as the below:
beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic " + encodeBase64("username" + ":" + "password")); },
it is not returning error, but also not returning results!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.