python - Unirest for Java -


i have python script, post data server url below. want achieve using unirest java. how add parameter/header values unirest post request in java

python script:

url = 'http://??????????????????/savetimeseriesdata'         params = {'clientid': 'admin', 'tenantid': '075841cb-d7fa-4890-84ea-fdd7d7c65b65', 'destinationid': 'timeseries','content-type': 'application/json','content':json.dumps(htlt_data.__dict__)}       try:             response= requests.post(url, params=params, proxies=proxies)             print response          except exception x:             print x     

the server endpoint code :

@requestmapping(value = "/savetimeseriesdata", method = requestmethod.post) public @responsebody string savemachinedata(         @requestheader(value = "authorization", required = false) string authorization,         @requestparam("clientid") string clientid, @requestparam("tenantid") string tenantid,         @requestparam("content") string content) { 

what unirest code in java? below code achieve same result python script

    unirest.post("http://???????????????/savetimeseriesdata")         .field("content", mo)         .field("tenantid", "075841cb-d7fa-4890-84ea-fdd7d7c65b65")         .field("clientid","admin")         .field("content-type","application/json")                                .asjson(); 

without more information believe simple bug location of quotes.

      .field("tenantid, "075841cb-d7fa-4890-84ea-fdd7d7c65b65") 

should be

      .field("tenantid", "075841cb-d7fa-4890-84ea-fdd7d7c65b65") 

note tenant id had no end quote. whole line may have been treated string literal. let me know if fixed bug


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -