2015-09-27 70 views
0

後,我有一個REST API與後續的端點:嫋嫋不按位置後

curl -L -H "Content-Type: application/json" -X POST -d "{\"source\" : \"3\", \"destination\" : \"5\"}" "http://localhost:8080/api/edge" |cjson 

這一要求不使後門柱位置URL(返回null,在這種情況下,我使用格式輸出的cjson)。如果在帖子後使用類似postman的工具,則正確的重定向完成。

這裏使用-i選項:提前

curl -i -H "Content-Type: application/json" -X POST -d "{\"source\" : \"3\", \"destination\" : \"5\"}" "http://localhost:8080/api/edge" 

HTTP/1.1 303 See Other 
Date: Sun, 27 Sep 2015 01:39:40 GMT 
Location: http://localhost:8080/api/customer 
Vary: Accept 
Content-Type: application/json;charset=ISO-8859-1 
Content-Length: 0 
Server: Jetty(7.6.8.v20121106) 

感謝

回答

1

使用-post303選項,以確保獲得一個POST消息的HTTP 303響應後,它將再次當它使用POST遵循重定向,所以:

curl -L -post303 -H "Content-Type: application/json" -X POST -d "{\"source\" : \"3\", \"destination\" : \"5\"}" "http://localhost:8080/api/edge" |cjson