Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Error 400 - Bad Request for import api call

 

 

I'm new in calling API, I can't find the reason this command in powershell raise an error

$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","1234567890123456")
$hdrs.Add("X-Qlik-User","UserDirectory=XXXXX;UserId=XXXXXXXXXXXXXX")

$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}

$Body = @{
filename="test_import.qvf"
} | ConvertTo-Json

$url = "https://XXXXX.XXXXXX.XXX:4242/qrs/app/import?name=test_import&xrfkey=1234567890123456"
$response = Invoke-RestMethod -Uri $url -Method POST -Headers $hdrs -Certificate $cert -Body $Body -ContentType 'application/json'
$response

 

Error:

 

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:15 char:13
+ $response = Invoke-RestMethod -Uri $url -Method POST -Headers $hdrs - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

PS: I can run other POST or Get command

Labels (3)
4 Replies
Highlighted
Creator III
Creator III

Before diving too deeply into this, why not just use Qlik-CLI? It's developed by Qlik and GREATLY improves usage and security of PowerShell and Qlik Sense. It will make your life so much easier when building a Qlik Sense & PowerShell ecosystem.
Highlighted
Creator III
Creator III

@parviz_asoodehfard  have you tried this?

Highlighted
Contributor III
Contributor III

The usage of power shell was a POC for me. After that, I need to run it by PDI and the base thing is enough for me, so I didn't try Qlik-CLI.

 

I found out I should use qrs/app/update.

I appreciate you @andoryuu 

 
Highlighted
Creator III
Creator III

Gotcha - glad it all worked out!