REST API - posting an XML works, but JSON does not

773 views
Skip to first unread message

harip...@gmail.com

unread,
Oct 30, 2015, 7:10:48 PM10/30/15
to eureka_netflix
Hello folks,

I'm trying to register an app via the REST API. I'm getting a 400 when trying to post JSON data, but posting an XML works.

Has anyone run into this before? Thanks in advance for your help


Request:
http://localhost:8080/eureka/v2/apps/test
Content-Type: application/xml

<?xml version="1.0" ?>
<instance>
<vipAddress>test</vipAddress>
<leaseInfo>
<evictionDurationInSecs>90</evictionDurationInSecs>
</leaseInfo>
<securePort>443</securePort>
<hostName>foo.local</hostName>
<secureVipAddress/>
<app>test</app>
<homePageUrl/>
<ipAddr>1.1.1.1</ipAddr>
<dataCenterInfo>
<name>MyOwn</name>
</dataCenterInfo>
<healthCheckUrl/>
<region>default</region>
<preferSameZone>False</preferSameZone>
<port>1010</port>
<statusPageUrl/>
<metadata>
<foo>bar</foo>
</metadata>
</instance>"

Response:
Status
204 No Content

Request:
http://localhost:8080/eureka/v2/apps/test
Content-Type: application/json

{
"instance": {
"vipAddress": "test",
"leaseInfo": {
"evictionDurationInSecs": 90
},
"securePort": 443,
"hostName": "foo.local",
"secureVipAddress": null,
"app": "test",
"homePageUrl": null,
"ipAddr": "1.1.1.1",
"dataCenterInfo": {
"name": "MyOwn"
},
"healthCheckUrl": null,
"region": "default",
"preferSameZone": false,
"port": 1010,
"statusPageUrl": null,
"metadata": {
"foo": "bar"
}
}
}

Response:
Status
400 Bad Request

{
error: "cannot parse request body"
}

--
Hari

Tomasz Bak

unread,
Nov 2, 2015, 12:02:30 PM11/2/15
to eureka_...@googlegroups.com
The JSON body is invalid. Here is a corrected version:

{
  "instance": {
    "vipAddress": "test",
    "leaseInfo": {
      "evictionDurationInSecs": 90
    },
    "securePort": {
      "$": 443,
      "@enabled": "false"
    },
    "hostName": "foo.local",
    "secureVipAddress": null,
    "app": "test",
    "homePageUrl": null,
    "ipAddr": "1.1.1.1",
    "dataCenterInfo": {
      "@class": "com.netflix.appinfo.MyDataCenterInfo",
      "name": "MyOwn"
    },
    "healthCheckUrl": null,
    "port": {
      "$": 1000,
      "@enabled": "true"
    },
    "statusPageUrl": null,
    "metadata": {
      "foo": "bar"
    }
  }
}

Fields region and perferSameZone does not belong to InstanceInfo object, but are part of EurekaClientConfig.

/Tomasz



--
You received this message because you are subscribed to the Google Groups "eureka_netflix" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eureka_netfli...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hari

unread,
Nov 2, 2015, 2:42:56 PM11/2/15
to eureka_...@googlegroups.com
That did work. Thanks, Tomasz!

sexyda...@gmail.com

unread,
Jun 12, 2018, 7:45:41 AM6/12/18
to eureka_netflix
בתאריך יום שבת, 31 באוקטובר 2015 בשעה 01:10:48 UTC+2, מאת harip...@gmail.com:
Reply all
Reply to author
Forward
0 new messages