Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This function is called by getCampaigns(). It uses the data that has been aggregated into
- //the reportObj object from previous functions to generate a Centro Report.
- function generateReport() {
- debugger;
- reportObj.flightDates.today = formatToday();
- var reportQuery = {
- "description": reportObj.brandName+'-'+reportObj.flightDates.today,
- "reportType": "CAMPAIGN",
- "aggregation": "DAILY",
- "fromDate": reportObj.flightDates.from,
- "toDate": reportObj.flightDates.today,
- "advertiserId": Number(advertiserId),
- "campaignIds": reportObj.campaigns
- };
- var authHeader = 'Bearer '+accessToken;
- //Create the FormData data object and append the file to it.
- var webForm = new FormData();
- var opts = {
- //Main url
- url: 'http://api.sitescout.com/advertisers/reports',
- headers: {'Authorization': authHeader},
- //contentType: 'application/x-www-form-urlencoded',
- contentType: 'application/json',
- //processData: false,
- type: 'POST',
- data: reportQuery,
- success: function(data){
- debugger;
- },
- //This error function is called if the POST fails for submitting the file itself.
- error: function(err) {
- debugger;
- console.error('AJAX request failed with following response: '+err.responseText);
- }
- };
- //Execute the AJAX operation.
- jQuery.ajax(opts);
- }
Advertisement
Add Comment
Please, Sign In to add comment