Answer the question
In order to leave comments, you need to log in
How can I pass the user in ajax request to 1C?
Greetings!
I make ajax GET request from js to 1C. There is an http service that gives the answer.
To get the necessary data, I just need to enter the following line in the browser:
localhost/base/hs/api/GetInfoByTel/?tel=9635123123
There will be a question about entering a user and password. After entering, the server will give a response.
Is it possible to make such a request directly from JS?
Now I'm getting the error "tatus Code: 401 Unauthorized".
But I don't know how to pass user and password. Tell?
Answer the question
In order to leave comments, you need to log in
If simple authorization, then you can try this:
$.ajax
({
type: "GET",
url: "http://localhost/base/hs/api/GetInfoByTel/?tel=9635123123",
dataType: 'json',
async: false,
headers: {
"Authorization": "Basic " + btoa("userName:password")
},
success: function (e){
console.log(e);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question