function postJournals() { var freeeApp = getService(); var accessToken = freeeApp.getAccessToken(); var requestUrl = "https://api.freee.co.jp/api/1/manual_journals"; var headers = { "Authorization" : "Bearer " + accessToken }; var entry_side = String( JournalsSheet.getRange(j, 4).getValues() ); var accountItemId = parseInt( JournalsSheet.getRange(j, 5).getValues() ); var taxCode = parseInt( JournalsSheet.getRange(j, 6).getValues() ); var partner_id = parseInt( JournalsSheet.getRange(j, 7).getValues() == "" ? 0 : JournalsSheet.getRange(j, 7).getValues() ); // null var itemId = parseInt( JournalsSheet.getRange(j, 8).getValues() == "" ? 0 : JournalsSheet.getRange(j, 8).getValues() ); // null var sectionId = parseInt( JournalsSheet.getRange(j, 9).getValues() == "" ? 0 : JournalsSheet.getRange(j, 9).getValues() ); // null var segment_1_tag_id = parseInt( JournalsSheet.getRange(j, 11).getValues() == "" ? 0 : JournalsSheet.getRange(j, 11).getValues() ); // null var amountDetails = parseInt( JournalsSheet.getRange(j, 13).getValues() ); var vat = parseInt( JournalsSheet.getRange(j, 14).getValues() ); var description = String( JournalsSheet.getRange(j, 15).getValues() ); var tag_data = JournalsSheet.getRange(j, 10).getValues(); // メモタグは1勘定科目に対して1つの想定 if ( tag_data == "" ) { tagIds = []; } else { tagIds = []; var get_tagId = parseInt( JournalsSheet.getRange(j, 10).getValues() ); tagIds.push( get_tagId ); }; details.push( { "entry_side" : entry_side, "account_item_id" : accountItemId, "tax_code" : taxCode, "partner_id" : partner_id, "item_id" : itemId, "section_id" : sectionId, "tag_ids" : tagIds, "segment_1_tag_id" : segment_1_tag_id, "amount" : amountDetails, // "vat" : vat, "description" : description }) //振替伝票を作成 var companyId = parseInt( JournalsSheet.getRange('A2').getValues() ); // parseInt関数を削除 //日付を取得しyyyy-MM-ddに変更 var date_set = JournalsSheet.getRange('B2').getValues(); var issueDate = Utilities.formatDate( new Date(date_set) , "JST" , "yyyy-MM-dd" ); var requestBody = { "company_id" : companyId, "issue_date" : issueDate, // "adjustment" : adjustment, "details" : details, }; // POSTオプション var options = { "method" : "POST", "contentType" : "application/json", "headers" : headers, "payload" : JSON.stringify( requestBody ), muteHttpExceptions : true }; var res = UrlFetchApp.fetch( requestUrl , options ); Logger.log('res -> ' + res)