Hi there,
I am new in the Espo-World. I am trying to write a GET-Request, to get an user id of a contact, filtered by emailAddress. I found the following information, that I can filter the contacts by emailAddress: https://docs.espocrm.com/development...s/#where-items
But I can't find any example, how to do it in Powershell. Every try results in a 500 respond from the API.
$whereFilter = "{
'type':'equals',
'attribute':'emailAddress',
'value':'+$mail+'
}"
$compressedWhereFilter = $whereFilter | ConvertFrom-Json | ConvertTo-Json -Depth 10 -Compress
$headers = New-Object"System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Api-Key", $xApiKey)
[System.Web.HttpUtility]::UrlEncode($CompressedFilters)
$encodedUri = "{0}Contact?where={1}"-f$baseUrl,[System.Web.HttpUtility]::UrlEncode($compressedWhereFilter)
return Invoke-RestMethod -Uri $encodedUri -Method 'GET' -Headers $headers | ConvertTo-Json
That is my last try. Without UrlEncode I get 500 too.
I would appreciate any help.
Greeting from Germany
Paul
>>>> EDIT:
I think I found a good solution:
$headers = New-Object"System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Api-Key", $xApiKey)
$url = $baseUrl+"Contact?where[0][type]=equals&where[0][attribute]=emailAddress&where[0][value]="+$mail
returnInvoke-RestMethod -Uri $url -Method 'GET' -Headers $headers
Here I got the idea to look at the ready URI to filter the contacts: https://www.youtube.com/watch?v=j6NZ41Uj7R8
Dzięki za video i pozdrowienia, emillod
I am new in the Espo-World. I am trying to write a GET-Request, to get an user id of a contact, filtered by emailAddress. I found the following information, that I can filter the contacts by emailAddress: https://docs.espocrm.com/development...s/#where-items
But I can't find any example, how to do it in Powershell. Every try results in a 500 respond from the API.
$whereFilter = "{
'type':'equals',
'attribute':'emailAddress',
'value':'+$mail+'
}"
$compressedWhereFilter = $whereFilter | ConvertFrom-Json | ConvertTo-Json -Depth 10 -Compress
$headers = New-Object"System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Api-Key", $xApiKey)
[System.Web.HttpUtility]::UrlEncode($CompressedFilters)
$encodedUri = "{0}Contact?where={1}"-f$baseUrl,[System.Web.HttpUtility]::UrlEncode($compressedWhereFilter)
return Invoke-RestMethod -Uri $encodedUri -Method 'GET' -Headers $headers | ConvertTo-Json
That is my last try. Without UrlEncode I get 500 too.
I would appreciate any help.
Greeting from Germany
Paul
>>>> EDIT:
I think I found a good solution:
$headers = New-Object"System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Api-Key", $xApiKey)
$url = $baseUrl+"Contact?where[0][type]=equals&where[0][attribute]=emailAddress&where[0][value]="+$mail
returnInvoke-RestMethod -Uri $url -Method 'GET' -Headers $headers
Here I got the idea to look at the ready URI to filter the contacts: https://www.youtube.com/watch?v=j6NZ41Uj7R8
Dzięki za video i pozdrowienia, emillod
Comment