We're currently experiencing an outage with our Citibank connection. Please visit our status page for more details and to subscribe to updates.

Trying to upload dependent tags with powershell, almost there...

ComportTomComportTom Expensify Customer Posts: 10 Expensify Newcomer

So I am following up on a prior post 'Powershell to update tags using API’ that looks like it ended with the user abandoning uploading a tag file, instead they embedded their independent tags into the json.

Using the code in their post below.....

.....................................................................

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

Add-Type -AssemblyName System.Web

$ptruserID = "......."

$ptrusersec = "......."

$PolicyID = "......."

$dependency = $true

$glCodes =$false

$header = $true

$setRequired=$true


$json = [ordered]@{

  "type"="update";

  "credentials"[email protected]{

   "partnerUserID"=$ptruserID;

   "partnerUserSecret"=$ptrusersec

  };

  "inputSettings"[email protected]{

   "type"="policy";

   "policyIDList"[email protected]($PolicyID)

  };

  "tags"[email protected]{

   "action"="replace";

   "source"="file";

   "config"[email protected]{

     "dependency"=$dependency;

     "glCodes"=$glCodes;

     "header"=$header;

     "setRequired"=$setRequired;

     "fileType"="csv"

     };

  };

 } | ConvertTo-Json

$url = "https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations"

$request = "requestJobDescription="

$file = Get-Item -Path C:\users\repetto\ExpensifyTags.csv

#$file = Import-CSV -Path C:\users\repetto\ExpensifyTags.csv

$encode = [System.Web.HttpUtility]::UrlEncode($file)

$body = $request + $json + "'&file='$encode"

Invoke-Webrequest -uri $url -body $body -Method Post

.......................................................

I get this result............

SatusCode       : 200

StatusDescription : OK

Content          : {"responseMessage":"Could not split the file on multiple lines. The file probably does not have proper End Of Line characters.","responseCode":666}


RawContent       : HTTP/1.1 200 OK

                   Access-Control-Allow-Origin: *

                   Access-Control-Allow-Methods: OPTIONS, GET, POST

                   Strict-Transport-Security: max-age=31536000;

                   Content-Length: 147

                   Content-Type: text/plain;charset=u...


Forms            : {}

Headers          : {[Access-Control-Allow-Origin, *], [Access-Control-Allow-Methods, OPTIONS, GET, POST], [Strict-Transport-Security, max-age=31536000;], [Content-Length, 147]...}


Images           : {}

InputFields      : {}

Links            : {}

ParsedHtml       : mshtml.HTMLDocumentClass

RawContentLength : 147

...................................................................

I verified that my csv ends each line with a crlf.


Here are the contents of the key variables:

PS C:\Users\Repetto> $file

Directory: C:\users\repetto

Mode               LastWriteTime        Length Name

-a----       2/11/2020 10:10 AM        362446 ExpensifyTags.csv     

~~~~~~~~~~~~~

PS C:\Users\Repetto> $encode

C%3a%5cusers%5crepetto%5cExpensifyTags.csv 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PS C:\Users\Repetto> $body

requestJobDescription={

   "type": "update",

   "credentials": {

               "partnerUserID": "…….",

                "partnerUserSecret": "……."

                 },

   "inputSettings": {

               "type": "policy",

               "policyIDList": ["……."]

                 },

   "tags": {

                "config": {

                               "setRequired": true,

                               "glCodes": false,

                               "header": true,

                               "dependency": true,

                               "fileType": "csv"

                           },

                "source": "file",

                "action": "replace"

            }

}'&file='C%3a%5cusers%5crepetto%5cExpensifyTags.csv 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can anyone help me understand this error and how to fix?


Thanks

Tagged:

Answers

Sign In or Register to comment.