简体   繁体   中英

How to send parameters in a GET call with restlet?

Confirmed the following in Curl:

This is working fine-

curl -X GET 'http://remoteUrl.com:8080/public/private/request/data?begin=12&end=20'

This is not working-

curl -X GET http://remoteUrl.com:8080/public/private/request/data?begin=12&end=20

So the whole purpose is to use the way first curl command in a java code with restlet to send the paramters in a GET request but unfortunately my code is not working.

Code:

    ClientResource clientResource = new     
    ClientResource("http://remoteUrl.com:8080/public/private/request/
    data?begin=12&end=20");
    Representation clientText = clientResource.get();

Error Log:

INFO: Unable to read a header
java.io.IOException: Parameter or extension has no name. Please check your value
    at org.restlet.engine.header.HeaderReader.readNamedValue(HeaderReader.java:499)
    at org.restlet.engine.header.CacheDirectiveReader.readValue(CacheDirectiveReader.java:65)
    at org.restlet.engine.header.CacheDirectiveReader.readValue(CacheDirectiveReader.java:38)
    at org.restlet.engine.header.HeaderReader.addValues(HeaderReader.java:282)
    at org.restlet.engine.header.CacheDirectiveReader.addValues(CacheDirectiveReader.java:50)
    at org.restlet.engine.header.HeaderUtils.copyResponseTransportHeaders(HeaderUtils.java:776)
    at org.restlet.engine.adapter.ClientAdapter.readResponseHeaders(ClientAdapter.java:129)
    at org.restlet.engine.adapter.ClientAdapter.updateResponse(ClientAdapter.java:191)
    at org.restlet.engine.adapter.ClientAdapter.commit(ClientAdapter.java:105)
    at org.restlet.engine.adapter.HttpClientHelper.handle(HttpClientHelper.java:119)
    at org.restlet.Client.handle(Client.java:153)

From the exception you give in your question, it seems that the value of the header Cache-Control isn't correct within the response. Restlet isn't able to parse it.

I guess that the value of this header is an empty string in the response...

Could you give us in your question the exact content of the response (mainly headers)?

Hope it helps you, Thierry

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