sean Hello Sean,
I tested it first on Swagger Opalstack API.
1.- Opalstack dashboard I copied API Token (Left side menu)
2.- Added it to Authorize popup in Swagger Opalstack docs
3.- Then in /api/v0/mariadb/add/ I click on "Try it out" button, then "Execute" button.
Responses Section:
CURL:
curl -X POST "https://my.opalstack.com/api/v0/mariadb/add/" -H "accept: application/json" -H "Authorization: theToken(added automatically)" -H "Content-Type: application/json" -d "{ \"name\": \"string\", \"server\": \"-some-value(auto-generated)\", \"external\": true, \"charset\": \"utf8\", \"dbuser\": \"some-value(autogenerated)\"}"
Request URL:
https://my.opalstack.com/api/v0/mariadb/add/
Code: 401
Details: Error
- Response Body:
{
"detail": "Authentication credentials were not provided."
}
- Response Headers:
allow: POST, OPTIONS
content-length: 58
content-type: application/json
date: Tue, 17 Nov 2020 23:27:08 GMT
server: nginx
status: 401
vary: Accept
www-authenticate: Token
x-content-type-options: nosniff
x-frame-options: DENY
Using Postman:
-Code auto-generated:
`var data = JSON.stringify({"name":"testDB","server":"serverId","external":true,"charset":"utf8","dbuser":"dbuserId"});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://my.opalstack.com/api/v0/mariadb/add/");
xhr.setRequestHeader("Authorization", "Bearer token here");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);`
Response:
{
"detail": "Authentication credentials were not provided."
}
Note: I removed the important data to show here.