0
我正在打电话给第三方api。这里是第三方的API信息和他们期望的:c# - 多部分表单数据发布请求的卷发等价物
POST /api/ HTTP/1.1
Host: testurl.com
Content-Type: multipart/form-data
curl https://testurl.com/api \
-H "Content-Type: multipart/form-data" \
-F "document[description]=meeting notes" \
-F "document[matter][id]=123" \
-F "document[document_category][name]=Offers" \
-F "document_version[last_modified_at]=2013-12-03T23:35:32+00:00" \
-F "document_version[uploaded_data][email protected]"
我需要编写一个c#等效post方法来发送这些信息。我在curl调用中关注了头部,但我不确定其余的表单数据。例如,“文档”和“文档_版本”以及它们各自的属性(或其他属性),我该如何传递这些信息?
这里是我的发现:http://www.briangrinstead.com/blog/multipart-form-post-in-c
我也正是在这一环节完成,但回来Bad Request
错误。更具体的错误:
{"error":"api error","message":"undefined method `key?' for nil:NilClass"}
我不知道发生了什么事情在第三API,所以我不知道这是什么错误表示。另外,我正在尝试发布pdf文档。
你有替代HttpWebRequest吗?另外,我会在哪里放置'document [description]'和那些东西? –