Okay
  Public Ticket #3785914
REST API
Closed

Comments

  •  12
    Willem-Jan Vroom started the conversation

    Hello,

    On Does B2BKing have a REST API? WP and WOO APIs - B2BKing it is mentioned that all the B2BKing information is available through the regular REST API. 

    I cannot find any B2BKing related endpoint in the REST API.

    I have used the following PowerShell code to find all the endpoints:

    Clear-Host
    $ConsumerKey    = "ck_blahblahblah"
    $CustomerKey    = "cs_somemoreblah"
    $URL            = "https://www.theurltomywebshop.nl"
    $EndPoints      = "/wp-json/wc/v3"
    $EndPoints_URL  = "$($url)$($Endpoints)"
    $Headers        = @{Authorization = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $ConsumerKey, $CustomerKey))) }
    $AllEndpoints   = Invoke-RestMethod -Method GET -Uri "$($EndPoints_URL)" -Headers $Headers
    $AllEndpoints.routes | Sort-Object

    My question is: where is all the B2BKing related information stored in the REST API?

    And I use PowerShell to query the REST API. 

    With kind regards,

    Willem-Jan Vroom


  •  12
    Willem-Jan Vroom replied

    Hello all,

    I have found the solution: the b2bking information is stored in the products' metadata.

    This Powershell-code gives you all the b2bking information:

    Clear-Host
    $ConsumerKey    = "ck_blahblahblah"
    $CustomerKey    = "cs_somemoreblah"
    $URL            = "https://www.theurltomywebshop.nl"
    $EndPoints      = "/wp-json/wc/v3"
    $EndPoints_URL  = "$($url)$($Endpoints)"
    $Headers        = @{Authorization = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $ConsumerKey, $CustomerKey))) }
    $Product        = Invoke-RestMethod -Method GET -Uri "$($EndPoints_URL)?per_page=1&page=1" -Headers $Headers      # Get the first product of the first page
    $Product.meta_data | Where-object {$_.Key -like 'b2bking*'} | Sort-Object -Property Key

    I hope this helps other persons too.

    With kind regards,

    Willem-Jan Vroom