Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3667

Upload csv using Invoke-RestMethod

$
0
0

I am trying to upload a local csv file to the import endpoint of 4me/xurrent using power shell. My latest version looks as follows and still receives an error.

$importUrl = "https://api.xurrent.qa/v1/import"# Create the headers for the import request$ImportHeaders = @{    Authorization = "Bearer $bearerToken""X-4me-Account" = "XXX""Content-Type" = "multipart/form-data"}# Create the body for the import request$importBody = @{    file = $ImportFile    type = "cis"}#QA Import to Xurrent with PROXY$importResponse = Invoke-RestMethod -Method Post -Uri $importUrl -Headers $ImportHeaders -inFile $importBody

This get's the following error:

Invoke-RestMethod : Der Pfad "C:\Users\XXX\System.Collections.Hashtable" kann nicht gefunden werden, da er nicht vorhanden ist.In \\tst_mgmt\4me_Import_Share\Scripts\QA - Import CI.ps1:65 Zeichen:19+ ... tResponse = Invoke-RestMethod -Method Post -Uri $importUrl -Headers $ ...+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : ObjectNotFound: (C:\Users\XXX...tions.Hashtable:String) [Invoke-RestMethod], ItemNotFoundException+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

ImportBody looks like this:

Name                           Value                                                                                                                                                                                                 ----                           -----                                                                                                                                                                                                 file                           C:\Users\XXX\Downloads\XXX.csv                                                                                                                       type                           cis  

Viewing all articles
Browse latest Browse all 3667

Trending Articles