var cbIntegrationId ="xxxxx";//I have this datavar clientId ="xxxxxx";//I have this datavar clientSecret ="xxxxxxx";//I have this datavar tableName ="xxxx";//I have this data//Get access token
$.post("https://"+ cbIntegrationId +".caspio.com/oauth/token",{
grant_type:"client_credentials",
client_id: clientId,
client_secret: clientSecret
},function(cbAuth){//Run POST call
$.ajax({
url:"https://"+ cbIntegrationId +".caspio.com/rest/v2/tables/"+ tableName +"/records?response=rows",
type:'POST',
data:'{ "SubmissionID": null, "Date_of_policy_sold": "13/08/2019","Broker_Code": "Afinidade1004","Drivers_Full_Name": "Amílcar Paco", "Drivers_BI_Number": "123456789012F","Phone_Number": "0258849279489", "Address": "Distrito Municipal 5 Matendene", "Email": "amilcarcpaco@gmail.com", "Type_Of_Cover": "Sedan/Light Duty Vehicle (6 months cover)","Amount_of_Months": "6", "Vehicle_Make_and_Model" : "Toyota Mark X", "Vehicle_Year_Model": "2008", "Vehicle_Registration_No": "AAV123MP", "Engine_Number": "GD028982", "Roadside": "Yes", "Cover_Start_Date": "14/08/2019", "Cover_End_Date": "14/2/20/2020", "Total_Amount": "2800", "Payment_Status":"cancel ", "IP": "127.0.0.0.0" }',//Define record values
headers:{"Authorization":"Bearer "+ cbAuth.access_token,//Extracts the access token from the initial authorization call"Content-Type":"application/json; harset=utf-8",//Required, otherwise 415 error is returned"Accept":"application/json"},
dataType:'json',
success:function(data){
console.log(data.Result);//Check the console to view the new added row},
error:function(data){
console.log(data.responseJSON);//Check the console to view error message if any}});});//But I am getting this error// ------{Message:"Authorization has been denied for this request."}Message:"Authorization has been denied for this request."
__proto__:Object//I'm trying to send data an external database using rest api. I ask for help.// I have the permissions, I Guess.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
Amilcar
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.