wordpress - 在 Microsoft Automate 中获取错误的 http 请求
问题描述
一旦在我们的在线商店中创建了新订单,我想向我的 MS 团队发送推送通知。我们目前正在使用 WooCommerce v3。
主意:
- 设置一个向 MS Automate 发送 post 请求的 webhook
- 接收 http 请求并发送 MS Teams 机器人消息,其中包含订购的产品、帐单名称和总价
因此,我通过使用woocommcer api 文档中的示例正文在邮递员中创建随机订单来测试这一点:
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": True,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 93,
"quantity": 2
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "10.00"
}
]
}
通过 Postman,我能够成功创建新订单并收到以下 json 响应:
{
"id": 727,
"parent_id": 0,
"number": "727",
"order_key": "wc_order_58d2d042d1d",
"created_via": "rest-api",
"version": "3.0.0",
"status": "processing",
"currency": "USD",
"date_created": "2017-03-22T16:28:02",
"date_created_gmt": "2017-03-22T19:28:02",
"date_modified": "2017-03-22T16:28:08",
"date_modified_gmt": "2017-03-22T19:28:08",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.35",
"total": "29.35",
"total_tax": "1.35",
"prices_include_tax": false,
"customer_id": 0,
"customer_ip_address": "",
"customer_user_agent": "",
"customer_note": "",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"transaction_id": "",
"date_paid": "2017-03-22T16:28:08",
"date_paid_gmt": "2017-03-22T19:28:08",
"date_completed": null,
"date_completed_gmt": null,
"cart_hash": "",
"meta_data": [
{
"id": 13106,
"key": "_download_permissions_granted",
"value": "yes"
}
],
"line_items": [
{
"id": 315,
"name": "Woo Single #1",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": "0.45",
"subtotal": "0.45"
}
],
"meta_data": [],
"sku": "",
"price": 3
},
{
"id": 316,
"name": "Ship Your Idea – Color: Black, Size: M Test",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"subtotal": "12.00",
"subtotal_tax": "0.90",
"total": "12.00",
"total_tax": "0.90",
"taxes": [
{
"id": 75,
"total": "0.9",
"subtotal": "0.9"
}
],
"meta_data": [
{
"id": 2095,
"key": "pa_color",
"value": "black"
},
{
"id": 2096,
"key": "size",
"value": "M Test"
}
],
"sku": "Bar3",
"price": 12
}
],
"tax_lines": [
{
"id": 318,
"rate_code": "US-CA-STATE TAX",
"rate_id": 75,
"label": "State Tax",
"compound": false,
"tax_total": "1.35",
"shipping_tax_total": "0.00",
"meta_data": []
}
],
"shipping_lines": [
{
"id": 317,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/727"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders"
}
]
}
}
现在我基本上只需要设置一个 woocommerce webhook,它会在创建新订单时向 MS Automate 发送一个发布请求。不输入请求正文 json 架构有效,我实际上收到了带有纯预设文本“新订单”的团队通知。
但是,当提供上述示例有效负载(邮递员或来自 api 文档的示例响应)以生成模式时,流程不再起作用,并且我收到了错误的请求 (400)。
这是 Automate 女士生成的架构:
{
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"parent_id": {
"type": "integer"
},
"number": {
"type": "string"
},
"order_key": {
"type": "string"
},
"created_via": {
"type": "string"
},
"version": {
"type": "string"
},
"status": {
"type": "string"
},
"currency": {
"type": "string"
},
"date_created": {
"type": "string"
},
"date_created_gmt": {
"type": "string"
},
"date_modified": {
"type": "string"
},
"date_modified_gmt": {
"type": "string"
},
"discount_total": {
"type": "string"
},
"discount_tax": {
"type": "string"
},
"shipping_total": {
"type": "string"
},
"shipping_tax": {
"type": "string"
},
"cart_tax": {
"type": "string"
},
"total": {
"type": "string"
},
"total_tax": {
"type": "string"
},
"prices_include_tax": {
"type": "boolean"
},
"customer_id": {
"type": "integer"
},
"customer_ip_address": {
"type": "string"
},
"customer_user_agent": {
"type": "string"
},
"customer_note": {
"type": "string"
},
"billing": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"company": {
"type": "string"
},
"address_1": {
"type": "string"
},
"address_2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"postcode": {
"type": "string"
},
"country": {
"type": "string"
},
"email": {
"type": "string"
},
"phone": {
"type": "string"
}
}
},
"shipping": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"company": {
"type": "string"
},
"address_1": {
"type": "string"
},
"address_2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"postcode": {
"type": "string"
},
"country": {
"type": "string"
}
}
},
"payment_method": {
"type": "string"
},
"payment_method_title": {
"type": "string"
},
"transaction_id": {
"type": "string"
},
"date_paid": {
"type": "string"
},
"date_paid_gmt": {
"type": "string"
},
"date_completed": {},
"date_completed_gmt": {},
"cart_hash": {
"type": "string"
},
"meta_data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"id",
"key",
"value"
]
}
},
"line_items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"product_id": {
"type": "integer"
},
"variation_id": {
"type": "integer"
},
"quantity": {
"type": "integer"
},
"tax_class": {
"type": "string"
},
"subtotal": {
"type": "string"
},
"subtotal_tax": {
"type": "string"
},
"total": {
"type": "string"
},
"total_tax": {
"type": "string"
},
"taxes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"total": {
"type": "string"
},
"subtotal": {
"type": "string"
}
},
"required": [
"id",
"total",
"subtotal"
]
}
},
"meta_data": {
"type": "array"
},
"sku": {
"type": "string"
},
"price": {
"type": "integer"
}
},
"required": [
"id",
"name",
"product_id",
"variation_id",
"quantity",
"tax_class",
"subtotal",
"subtotal_tax",
"total",
"total_tax",
"taxes",
"meta_data",
"sku",
"price"
]
}
},
"tax_lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"rate_code": {
"type": "string"
},
"rate_id": {
"type": "integer"
},
"label": {
"type": "string"
},
"compound": {
"type": "boolean"
},
"tax_total": {
"type": "string"
},
"shipping_tax_total": {
"type": "string"
},
"meta_data": {
"type": "array"
}
},
"required": [
"id",
"rate_code",
"rate_id",
"label",
"compound",
"tax_total",
"shipping_tax_total",
"meta_data"
]
}
},
"shipping_lines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"method_title": {
"type": "string"
},
"method_id": {
"type": "string"
},
"total": {
"type": "string"
},
"total_tax": {
"type": "string"
},
"taxes": {
"type": "array"
},
"meta_data": {
"type": "array"
}
},
"required": [
"id",
"method_title",
"method_id",
"total",
"total_tax",
"taxes",
"meta_data"
]
}
},
"fee_lines": {
"type": "array"
},
"coupon_lines": {
"type": "array"
},
"refunds": {
"type": "array"
},
"_links": {
"type": "object",
"properties": {
"self": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
},
"required": [
"href"
]
}
},
"collection": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string"
}
},
"required": [
"href"
]
}
}
}
}
}
}
错误详情:
预先感谢大家的帮助。这可能是我想念的微不足道的事情。
干杯,亚历克斯
解决方案
推荐阅读
- python - 是否总是需要增加 Py_True/Py_False 引用计数?
- listview - 如何在颤动中使用复选框从列表中搜索数据
- arrays - 排序数组返回无序数组
- unity3d - 如何在统一 2019.1.9 中修复“网络已过时”?
- java - Spring Boot - Camel - Maven:如何添加我自己的父依赖项以及 Spring Boot 依赖项?
- webpack - 如何通过 CDN 将 ArcGIS Javascript API 包含在 Webpack 中以与 Stimulus 一起使用?
- kotlin - java.lang.NoClassDefFoundError: com/google/api/core/ApiFuture
- postgresql - 优化将表与自身进行数百万行比较的查询
- kdb - 如何删除qsql中last关键字的冗余使用
- python - pkey 约束的重复值