Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2109

Joomla! 4.x Coding • API connection to Joomla 4 not working via PowerShell

$
0
0
Hello all,

Not 100% shure if this should be under coding but I do have troubles with API access via Windows PowerShell.

Steps to reproduce the issue
Open Powershell, for example PowerShell 5 or 7 both x86 and x64 bits.
Fill in the code placed below under "Used code".

Expected result
JSON output of all Joomla articles and their settings.

Actual result
PowerShell 7.4.2: Invoke-RestMethod: Could not match accept header
PowerShell 5.1: Invoke-RestMethod: The remote server returned an error: (406) Not Acceptable

System information (as much as possible)
Windows 11 Pro 23H2 with PowerShell 7.4.2.
Joomla 4.4.4.

Additional comments
When using Postman I can get a connection, but via PowerShell it looks like Joomla don't accept the application/json header.
I use PowerShell to do a lot of automations involving Joomla.

Used code:

Code:

$token = <BEARER_JOOMLA_API_KEY>$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"$headers = @{    'Authorization'='Bearer $token'    'Content-Type'='application/json'}$response = Invoke-RestMethod 'https://<DOMAIN_NAME>/api/index.php/v1/content/articles' -Method 'GET' -Headers $headers$response | ConvertTo-Json
Hopefully someone can help me further with this.
I already dropped this issue on the Joomla Github but received a reaction that this does not looks like a bug.
And to post it in the forums. https://github.com/joomla/joomla-cms/issues/43498

Thank you!

Statistics: Posted by SoundHunter — Mon Jun 17, 2024 8:12 pm



Viewing all articles
Browse latest Browse all 2109

Trending Articles