Hi Kirti,
I believe X-Kannel-Headers are meant to be set in response to a SMS-Service
Post.
For sms push (sendsms cgi) you should use cgi variables (see
http://kannel.org/download/1.5.0/userguide-1.5.0/userguide.html#AEN4660)

In any case, i think that is not the proper way to set HTTP headers for a
request. See:
http://stackoverflow.com/questions/13512188/setting-headers-in-post-request-with-java

I am copying kannel users mailing list

Regards,
Germán


2015-10-08 7:29 GMT-03:00 Kirti Mandwade <kirti.mandw...@gmail.com>:

> Hi German,
>
> Can you help me in how to use X-Kannel Header.
> Here is what i tried
>
> String url = "http://u.v.w.x:13003/cgi-bin/sendsms";;
>
>   CloseableHttpClient httpClient = HttpClients.createDefault();
>   HttpPost httpPost = new HttpPost(url);
>   httpPost.setHeader("content-type", "text/plain");
>   CloseableHttpResponse response = null;
>   StringEntity entity = null;
>   List <NameValuePair> headers = new ArrayList <NameValuePair>();
>   headers.add(new BasicNameValuePair("X-Kannel-Username", "abc"));
>   headers.add(new BasicNameValuePair("X-Kannel-Password", "123"));
>   headers.add(new BasicNameValuePair("X-Kannel-From", "abc123abc"));
>   headers.add(new BasicNameValuePair("X-Kannel-To", "278132300004"));
>   headers.add(new BasicNameValuePair("X-Kannel-SMSC", "send"));
>
>     entity = new StringEntity("hello", ContentType.create(
>             "text/plain"));
>
>
> httpPost.setEntity(new UrlEncodedFormEntity(headers));
> httpPost.setEntity(entity);
>
>
>
>        response = httpClient.execute(httpPost);
>                  System.out.println(response.getStatusLine());
>
>        EntityUtils.consume(entity);
>
>
>
> I have set accept-x-kannel headers to true in sms-service group of kannel
> configuration
>
> group = sms-service
> accept-x-kannel-headers = true
>
>
> Sending SMS using POST method with XML is working perfectly.
> Can you tell me what i am doing wrong here.
>
>
> Regards
> Kirti
>
>
>
>


-- 


*Germán Bobr *german.b...@redmondsoftware.com
[image: Description: redmond]

Reply via email to