You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用RestSharp调用Etsy API创建Listing时含变音符号(ä,ö,ü)导致signature_invalid问题求助

Fixing Invalid OAuth Signature When Using Umlauts (ä,ö,ü) in Etsy API Listing Requests

我之前对接Etsy API时也碰到过一模一样的问题!这个错误的核心原因是OAuth 1.0签名生成时,特殊字符(比如变音符号)的编码方式不符合Etsy的要求。你现在直接把带变音符号的参数拼在URL里,RestSharp的默认URL拼接逻辑没有按照OAuth标准正确处理这些字符,导致签名验证失败。

从你提供的debug_sbs能看到,标题里的Ä被编码成了%C3%84,这本身是UTF-8的正确编码,但问题出在参数传递方式上——手动拼接URL会让RestSharp生成签名时,对整个URL的编码处理和Etsy服务器端的计算逻辑不一致。

解决方案:改用AddParameter传递参数,而非手动拼接URL

直接修改你的代码,把所有参数通过request.AddParameter方法添加,不要拼在URL字符串里。RestSharp会帮你按照OAuth 1.0的标准(RFC 5849)正确编码每个参数,包括变音符号,这样生成的签名就能和Etsy服务器端匹配了。

修改后的代码如下:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var restClient = new RestClient("https://openapi.etsy.com/v2");
restClient.Authenticator = OAuth1Authenticator.ForAccessToken(
    etsyCredentials.ConsumerKey, 
    etsyCredentials.ConsumerSecret, 
    etsyCredentials.OAuth_Token, 
    etsyCredentials.OAuth_Token_Secret, 
    RestSharp.Authenticators.OAuth.OAuthSignatureMethod.HmacSha1);

// 初始化POST请求,只保留基础路径
var request = new RestRequest("/listings", Method.POST);

// 逐个添加所有参数,包括带变音符号的title
request.AddParameter("quantity", "1");
request.AddParameter("title", "testartikel mit Ä");
request.AddParameter("description", "Testartikel, Bitte nicht kaufen.");
request.AddParameter("price", "0.99");
request.AddParameter("taxonomy_id", "6451");
request.AddParameter("who_made", "i_did");
request.AddParameter("when_made", "2010_2019");
request.AddParameter("is_supply", "false");
request.AddParameter("shipping_template_id", "60205488400");
request.AddParameter("renew", "True");
request.AddParameter("state", "draft");
request.AddParameter("language", "de");

IRestResponse irestResponse = restClient.Execute(request);

关键注意事项:

  • 绝对不要手动对参数值进行URL编码(比如把Ä改成%C3%84),让RestSharp自动处理——手动编码会导致双重编码,同样会触发签名无效错误。
  • 所有包含特殊字符的参数(比如标题、描述)都必须通过AddParameter传递,避免直接拼在URL路径里。
  • 确保你的RestSharp版本是较新的,旧版本可能存在编码逻辑的bug,建议升级到最新稳定版。

这样修改后,你的请求就能正确处理变音符号,OAuth签名也能通过Etsy的验证了。

内容的提问来源于stack exchange,提问作者Daniel Hagen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 11:52:38