http 和 POST 方法的问题

问题描述 投票:0回答:1

我们正在尝试对 Google 商家工具进行提要刷新。

连接和发送工作完美,我们只是在发送 POST 而不是标准 GET 方法时遇到问题 ... 我们正在使用经典的asp

M_JSON 是 JSON content-api-key.json 文件

设置 xmlHttp = Server.CreateObject("Chilkat_9_5_0.Http")

xmlHttp.AuthToken = M_JSON

设置 sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")

成功 = xmlHttp.QuickGetSb("https://shoppingcontent.googleapis.com/content/v2.1/xxxxxxxxx/datafeeds/xxxxxxxx/fetchNow",sbResponseBody)

Chilkat日志: 快速获取Sb: Dll日期: 2023 年 7 月 28 日 Chilkat版本:9.5.0.95 解锁前缀:SMPEUR 解锁状态:2 架构:小端; 32位 语言:ActiveX 详细日志记录:0 网址:https://shoppingcontent.googleapis.com/content/v2.1/xxxxxxxxx/datafeeds/xxxxxxxx/fetchNow http请求字符串: a_quickReq: 快速Http请求: http动词:GET 网址:https://shoppingcontent.googleapis.com/content/v2.1/xxxxxxxxx/datafeeds/xxxxxxxxx/fetchNow 打开Http连接: 直接打开与 HTTP 服务器的连接。 http主机名:shoppingcontent.googleapis.com http端口:443 tls:正确 HTTPS 安全通道已建立。 --openHttpConnection 构建快速请求: 生成起始线: startLine: GET /content/v2.1/xxxxxxxxx/datafeeds/xxxxxxxx/fetchNow HTTP/1.1 --genStartLine --buildQuickRequest 发送请求头: sendHeaderElapsedMs: 0 --发送请求头 读取响应头: 进程握手记录: 处理握手消息: 处理NewSessionTicket: 票证生命周期:0x2a300 Ticket_lifetime: 172800 票证年龄添加:0x77e75b8f 票证年龄地址:2011650959 m_nonce_size: 1 票长度: 229 --processNewSessionTicket --process握手消息 处理握手消息: 处理NewSessionTicket: 票证生命周期:0x2a300 Ticket_lifetime: 172800 票证年龄添加:0xcbc3ee81 票证年龄地址:3418615425 m_nonce_size: 1 票长度: 229 --processNewSessionTicket --process握手消息 --process握手记录 --读取响应头 状态代码:404 状态文本:未找到 --quickHttpRequest --a_quickReq 将ResponseBody转换为Utf8: 响应Hdr字符集:UTF-8 --convertResponseBodyToUtf8 由于 HTTP 响应代码而返回失败状态。 --httpRequestStr 失败的。 --QuickGetSb --ChilkatLog

html json http-post
1个回答
0
投票

要使用 Chilkat 在经典 ASP 中从 GET 请求切换到 POST 请求,请尝试:

  1. 将 JSON 数据准备为字符串。
  2. 使用Chilkat.Http对象的HttpPostStr方法发送POST请求。
  3. 将 URL、内容类型(对于 JSON 数据,通常为“application/json”)和 JSON 字符串传递给 HttpPostStr。

Set xmlHttp = Server.CreateObject("Chilkat_9_5_0.Http")
xmlHttp.AuthToken = M_JSON ' Your authentication token

' Your JSON data as a string
jsonStr = "{""key"":""value""}" ' Replace with your actual JSON data

' The URL you're posting to
url = "https://shoppingcontent.googleapis.com/content/v2.1/xxxxxxxxx/datafeeds/xxxxxxxx/fetchNow"

' Sending the POST request
Set sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = xmlHttp.PostJson(url, jsonStr, sbResponseBody)

If success Then
    ' Process success
    responseText = sbResponseBody.GetAsString()
    ' Do something with responseText
Else
    ' Handle error
    errorMsg = xmlHttp.LastErrorText
    ' Do something with errorMsg
End If

确保将 URL 替换为您的实际端点,并将“key”:“value”替换为您的实际 JSON 数据。

© www.soinside.com 2019 - 2024. All rights reserved.