Если я использую такие методы, как PUT, DELETE или GET, у меня нет проблем.$wresponse
- это обычный ответ JSON.
Когда я пытаюсь использовать POST, я получаю ответ, похожий на HTML.
Код выполнения:
$wresponse = Invoke-RestMethod -Uri https://**************/wp-json/wc/v3/products/ -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body -ContentType "application/json" -Method post
После выполнения продуктаобычно добавляется в базу данных, но ответ выглядит следующим образом (JSON после del tag?):
<head>
<title>Document Moved</title>
</head>
<body>
<h1>Object Moved</h1>This document may be found
<a HREF="https://*************/wp-json/wc/v3/products/1507">here</a>
</body> {"id":1507,"name":"test article","slug":"test-article","permalink":"https:\/\/************\/izdelek\/testni-artikel\/","date_created":"2019-01-29T11:29:15","date_created_gmt":"2019-01-29T10:29:15","date_modified":"2019-01-29T11:29:15","date_modified_gmt":"2019-01-29T10:29:15","type":"simple","status":"publish","featured":false,"catalog_visibility":"visible","description":"bla bla bla","short_description":"bla bla bla","sku":"","price":"10","regular_price":"20","sale_price":"10","date_on_sale_from":null,"date_on_sale_from_gmt":null,"date_on_sale_to":null,"date_on_sale_to_gmt":null,"price_html":"
<del>
<span class=\"woocommerce-Price-amount amount\">
<span class=\"woocommerce-Price-currencySymbol\">€<\/span>20.00<\/span><\/del>
<ins>
<span class=\"woocommerce-Price-amount amount\">
<span class=\"woocommerce-Price-currencySymbol\">€<\/span>10.00<\/span><\/ins>","on_sale":true,"purchasable":true,"total_sales":0,"virtual":false,"downloadable":false,"downloads":[],"download_limit":-1,"download_expiry":-1,"external_url":"","button_text":"","tax_status":"taxable","tax_class":"","manage_stock":false,"stock_quantity":null,"stock_status":"instock","backorders":"no","backorders_allowed":false,"backordered":false,"sold_individually":false,"weight":"812","dimensions":{"length":"100","width":"200","height":"300"},"shipping_required":true,"shipping_taxable":true,"shipping_class":"","shipping_class_id":0,"reviews_allowed":true,"average_rating":"0","rating_count":0,"related_ids":[298,342,229,224,32],"upsell_ids":[],"cross_sell_ids":[],"parent_id":0,"purchase_note":"","categories":[{"id":17,"name":"BABY LINE","slug":"baby-line"}],"tags":[],"images":[],"attributes":[],"default_attributes":[],"variations":[],"grouped_products":[],"menu_order":0,"meta_data":[],"_links":{"self":[{"href":"https:\/\/***************\/wp-json\/wc\/v3\/products\/1507"}],"collection":[{"href":"https:\/\/*******************\/wp-json\/wc\/v3\/products"}]}}
В чем может быть проблема?Или это нормально, и я должен каким-то образом извлечь JSON из этого ответа?