question

doranhandman avatar image
doranhandman asked hilarymiller answered

How do I test Hosted checkout with Powershell? I keep getting Auth errors.

How do I test Hosted checkout with PowerShell I keep getting Authtication errors.

Below is the response from Powershell:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

At line:30 char:13

+ $response = Invoke-RestMethod 'https://dev1.dev.clover.com/invoicingc ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

API Token
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered

What steps are you following? It sounds like you don't have a valid api token. Maybe this will help - https://www.clover.com/help/create-an-api-token-hosted-checkout/.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

doranhandman avatar image
doranhandman answered

I have gone through these documents. I used the Powershell script supplied in docs, and replaced the required fields I.e. MerchantID, PrivateKey and Email, resulting in the following error:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

At line:30 char:13

+ $response = Invoke-RestMethod 'https://dev1.dev.clover.com/invoicingc ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

doranhandman avatar image
doranhandman answered David Marginian Deactivated commented

I have been referencing the documentation, I used the Windows Powershell script for testing which was in the documentation, replacing the required fields from my dashboard / API Token interface (MerchID PrvtKey and email), resulting in the following error:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

At line:30 char:13

+ $response = Invoke-RestMethod 'https://dev1.dev.clover.com/invoicingc ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Where are you getting this powershell script? It looks like it is hitting one of our dev environments that won't be available to you. Are you trying to hit production or sandbox?

0 Likes 0 ·
doranhandman avatar image
doranhandman answered David Marginian Deactivated commented

I am trying to hit the sandbox I believe. I created the API token in the sandbox account.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Search for dev1 in the script and replace it with sandbox.

0 Likes 0 ·
doranhandman avatar image
doranhandman answered

I tried to reply to this answer in the forum by clicking the link below, but I could only see your previously answered question 23 hrs. ago.

I go the script from:

https://docs.clover.com/docs/testing-your-hosted-checkout-integration-windows

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

doranhandman avatar image
doranhandman answered

I am trying to hit the sandbox I believe. I created the API token in the sandbox account.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

davidyon avatar image
davidyon answered davidyon commented

I ran into this problem as well. When is the documentation going to be updated? And while you're at it, the "lastName" line in the PowerShell script has a bug in the termination of the quotes.


3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·
Thanks I created an issue for our docs team. Not sure why the test card updates are taking so long.
0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ David Marginian ♦♦ commented ·
The powershell script has been updated.
0 Likes 0 ·
davidyon avatar image davidyon David Marginian ♦♦ commented ·
Yep, both issues are fixed. Thanks much.
1 Like 1 ·
timeline avatar image
timeline answered

Type the following cmdlet and then hit Enter: "Restart-Service WinRM". It's time to test the connection, From the MID Server execute the following cmdlet into PowerShell and then hit Enter: "Test-WsMan <Target IP>" and This simple command tests whether the WinRM service is running on the remote Host. retro bowl college

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

roseharris avatar image
roseharris answered

To test Hosted Checkout with PowerShell, ensure your API key is correct and included in the headers. Authentication errors are common; verifying credentials is essential, just like ensuring solar panels energy are correctly installed.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hilarymiller avatar image
hilarymiller answered

It looks like you're running into authentication issues while testing the Hosted Checkout with PowerShell. A 401 Unauthorized error usually means that your credentials aren't being accepted. Make sure you're using the correct API keys and any required headers in your request.For a change of pace, if you enjoy online games, Pokerogue and Pokerogue Dex offer a great community and resources for poker enthusiasts!

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community