2017-06-02 54 views
0

我有两个调用RESTlet NetSuite Web服务的C#应用​​程序发布数据 - GET和POST。GET工作,而POST无法通过RESTlet调用

GET正常工作 - 我收到成功答案。这是它的外观上的小提琴手:

https://some.netsuite.uri&deploy=1&my_id=123&my_a_id=Test66&param=4&amount=66 HTTP/1.1 
Authorization: NLAuth nlauth_account=1234567_SB9, [email protected], nlauth_signature=Pass123456, nlauth_role=3 
Accept: application/json 
Host: rest.eu1.netsuite.com 
Connection: Keep-Alive 

返回

success 

但我想这是更正确使用POST。但它失败:

POST https://some.netsuite.uri&deploy=1 HTTP/1.1 
Authorization: NLAuth nlauth_account=1234567_SB9, [email protected], nlauth_signature=Pass123456, nlauth_role=3 
Accept: application/json 
Content-Type: application/x-www-form-urlencoded 
Host: some.netsuite.uri 
Cookie: JSESSIONID=**************************************; lastUser=1234567_SB9_1282_3; NS_ROUTING_VERSION=LAGGING; NS_VER=2017.1.0 
Content-Length: 51 
Expect: 100-continue 
Connection: Keep-Alive 

my_id=123&my_a_id=Test66&param=4&amount=66 

返回HTML:

An unexpected error has occurred. Please click here to notify support and provide your contact information. 

可能是什么问题?

UPD

我已经更新了POST JSON数据:

POST https://some.netsuite.uri&deploy=1 HTTP/1.1 
Authorization: NLAuth nlauth_account=XXXXX, nlauth_email=XXXXX, nlauth_signature=XXXXX, nlauth_role=3 
Accept: application/json 
Content-Type: application/json; charset=utf-8 
Host: rest.eu1.netsuite.com 
Cookie: JSESSIONID=**************************************; lastUser=1234567_SB9_1282_3; NS_ROUTING_VERSION=LAGGING; NS_VER=2017.1.0 
Content-Length: 69 
Expect: 100-continue 

{"my_id":"975","my_a_id":"Test66","param":"4","amount":"66"} 

并得到了答案:

HTTP/1.1 200 OK 
    Date: Sat, 03 Jun 2017 06:21:46 GMT 
    Server: Apache 
    Cache-Control: No-Cache 
    Pragma: No-Cache 
    Content-Length: 41 
    Expires: 0 
    Edge-Control: no-store 
    X-N-OperationId: 486c2d20-099d-446b-9788-4816db59a1fd 
    Set-Cookie: JSESSIONID=64............................. 
; path=/ 
    NS_RTIMER_COMPOSITE: 1688996695:706172746E6572733030312E70726F642E6475622E6E65746C65646765722E636F6D:80 
    P3P: CP="CAO PSAa OUR BUS PUR" 
    Vary: User-Agent 
    Content-Type: application/json; charset=utf-8 

    [email protected] 

从一个侧面,我想HTTP/1.1 200 OK意味着服务器已接受的数据。但是什么意思[email protected]

+1

乍一看你的URL看起来不正确: 的https://some.netsuite.uri&deploy=1 应该 HTTPS: //some.netsuite.uri?deploy=1 – user3075978

+0

看起来你已经粘贴了你的实际凭证 - 确保尽快更改你的密码! – michoel

回答

1

您的请求内容类型错误Content-Type: application/x-www-form-urlencoded。 Restlets只支持application/json。请确保你在你的请求主体发送一个有效的JSON:

{ 
    "my_id": 123, 
    "my_a_id": "Test66", 
    "param": 4, 
    "amount": 66 
}