简体   繁体   中英

GET works while POST fails to RESTlet call

I have two calls to RESTlet NetSuite web service from C# application that post data - GET and POST.

GET works fine - I receive success answer. This is how it looks on Fiddler:

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, nlauth_email=xx@xx.com, nlauth_signature=Pass123456, nlauth_role=3
Accept: application/json
Host: rest.eu1.netsuite.com
Connection: Keep-Alive

Returns

success

But I suppose it is more correct to use POST. But it fails:

POST https://some.netsuite.uri&deploy=1 HTTP/1.1
Authorization: NLAuth nlauth_account=1234567_SB9, nlauth_email=xx@xx.com, 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

Returns HTML:

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

What might be wrong?

UPD

I have updated POST with JSON data:

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"}

And got answer:

    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

    org.mozilla.javascript.Undefined@54b896b0

From one side I suppose HTTP/1.1 200 OK means server has accepted data. But what means org.mozilla.javascript.Undefined@54b896b0 ?

Your request Content Type is wrong Content-Type: application/x-www-form-urlencoded . Restlets only support application/json . Make sure that you are sending a valid JSON in your request body:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM