and trying to get an API key. and the website gave me some curl code. well since im a korean, not sure whether i understood the description right or not. anyways,
curl --insecure -X POST
--header "Content-Type: application/x-www-form-urlencoded"
--header "Accept: application/json"
--data-urlencode "grant_type=urn:grant-type:apikey"
--data-urlencode "apikey=$API_KEY" "https://iam~~"
this is the code and I wanna know where to put '--data-urlencode' part on an ajax call code..
function to_ajax(){
$.getJSON("http://localhost~~/",
function(data){
$.ajax({
dataType: 'application/json',
data : {"grant_type":"urn:grant-type:apikey"
,"apikey=$API_KEY":"https://iam~~"},
headers: {"Content-Type" : "application/x-www-form-urlencoded" ,
"Accept": "application/json" } ,
success: function(msg) {
console.log(msg);
}
});
})
}
this is where i've been reached...shame.. and when I run this, I get CORS error. and the IBM explained like this 'The API Gateway can run the API CORS action to handle cross-origin resource sharing (CORS) requests for an API.
CORS is disabled for an API by default, in which case the API Gateway passes all CORS requests to the back end for handling. When preflight requests are passed to the back end, an OPTIONS operation must be defined for each path that can be the target of the request. Otherwise, the preflight request to that path can result in an error.'
so this means they allowed all access, right?