我有一个
fifos(0).suggestName("FirstFifo")
fifos(1).suggestName("SecondFifo")
请求:
此curl -X POST -u "uname":"pwd" --header "Content-Type:application/json" --data "{\"input\": {\"text\": \"Hello there\"}}"
请求的等效ajax
请求是什么?
curl
请更正ajax请求。
答案 0 :(得分:0)
您必须在授权标头中发送用户/密码,类似于此https://stackoverflow.com/a/11960692/3331845
$.ajax({
type: 'post',
url: "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/XXX...XXX/message?version=20XX-XX-XX",
data: "{ \"input\": {\"text\": \"Hello\"}} ",
headers : {'Content-Type' : 'application/json' },
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
},
success:function(response)
{
console.log("Success!!");
},
error : function(xhr, status, error)
{
console.log("Status of error message" + status + "Error is" + error);
}
});