{"responseMessage":"Invalid requestJobDescription: onReceive.immediateResponse is missing or malform

g_taylorabbottg_taylorabbott Expensify Customer Posts: 3

Error When making call via API using c#..Any help would be appreciated.


public string ExportADP()

        {

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations");

            httpWebRequest.ContentType = "application/x-www-form-urlencoded";

            httpWebRequest.Method = "POST";

            ServicePointManager.Expect100Continue = true;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls

                   | (SecurityProtocolType)768

                   | (SecurityProtocolType)3072

                   | SecurityProtocolType.Ssl3;

           

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

            {


 

                string json = new JavaScriptSerializer().Serialize(new

                {


 

                    type = "file",

                    

                    credentials = new

                    {

                        partnerUserID = "XXXXXXX",

                        partnerUserSecret = "XXXXXXXXXXXXX"

                    },

                    onReceive = new

                    {

                        immediateResponse = ["returnRandomFileName"]

                    },

                    inputSettings = new

                    {

                        type = "combinedReportData",

                        reportState = "APPROVED",

                        limit="10",

                        filters = new

                        {

                            startDate = "2019-09-01",

                            endDate = "2019-09-08",

                            markedAsExported = "Expensify Export"

                        }

                    },

                    outputSettings = new

                    {

                        fileExtension = "csv",

                        fileBasename = "Expensify"

                    }, 


 

                });

               

                


 

                String templateFile = @"<#if addHeader == true> 

                    Merchant,Original Amount,Category,Report number,Expense number<#lt>

                </#if>

                <#assign reportNumber = 1>

                <#assign expenseNumber = 1>

                <#list reports as report>

                    <#list report.transactionList as expense>

                    ${expense.merchant},<#t>

                    <#-- note: expense.amount prints the original amount only --> $

                    {expense.amount},<#t>

                    ${expense.category},<#t>

                    ${reportNumber},<#t>

                    ${expenseNumber}<#lt>

                    <#assign expenseNumber = expenseNumber + 1>

                </#list>

                    <#assign reportNumber = reportNumber + 1>

                </#list> ";


 

                //template = "expensify_export.ftl";

                String test = "requestJobDescription=" + json + "&template=" + templateFile;


 

                byte[] byteArray = Encoding.UTF8.GetBytes(test);


 

                Stream dataStream = httpWebRequest.GetRequestStream();

                dataStream.Write(byteArray, 0, byteArray.Length);


 

            }

            HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

            {

                var result = streamReader.ReadToEnd();


 

                return result;

            }

           

        }

Sign In or Register to comment.