07-20-2021 01:20 AM
I try Apache HttpClient to send text message to Cisco VoIP Phones.
HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new StringEntity(body, ContentType.TEXT_XML)); httpPost.addHeader(new BasicScheme().authenticate(usernamePasswordCredentials, httpPost, null));
The XML message looks like this
String body = """ XML= <CiscoIPPhoneText> <Title>...</Title> <Prompt>...</Prompt> <Text>...</Text> </CiscoIPPhoneText> """;
The URL used is with IP adress like
String url = "https://<ip-adress>/CGI/Execute";
Wenn executing the POST request
HttpResponse response = closeableHttpClient.execute(httpPost);
I recieve status code 400 and
<CiscoIPPhoneError Number="1"></CiscoIPPhoneError>
I don't know what that means and what the problem is with the POST request.
The authentication seams to have been successful, because if I remove the part
httpPost.addHeader(new BasicScheme()...
then I get 401.
Here is the console output on the VoIP phone
JAVA-HTTP JNI| processHttpRequest: return from http response, [res] = 0 JAVA-HTTP JNI| httpServerHandler: uri=/CGI/Execute JAVA-Thread-21|cip.http.HttpPushRequest:? - XML not initialized! JAVA-HTTP JNI| Java_cip_http_NativeHttpTask_updateCgiRequest: conId=0, state=3, error=400 JAVA-HTTP JNI| httpServerHandler: pushStatus=3, pushError=400 JAVA-HTTP JNI| processStatusResponse: call mg_printf with HTTP/1.1 400 Bad Request Content-Type: text/xml Content-Length: 50 Content: <CiscoIPPhoneError Number="1"></CiscoIPPhoneError> JAVA-SSL shutdown.
07-23-2021 11:56 AM
The content of the HTTP POST should be in application/x-www-form-urlencoded format, so specifying the right content header and encoding the XML=[data], something like:
POST /CGI/Execute HTTP/1.1 Host: 10.99.58.26 Authorization: Basic ZHN0YXVkdDpwYXNzd29yZA== User-Agent: curl/7.74.0 Accept: */* Content-Length: 427 Content-Type: application/x-www-form-urlencoded XML=%3CCiscoIPPhoneText%3E%0A%20%20%20%20%3CText%3EHello%20World%3C%2FText%3E%0A%20%20%20%20%3CSoftKeyItem%3E%0A%20%20%20%20%20%20%20%20%3CName%3ECustom%3C%2FName%3E%0A%20%20%20%20%20%20%20%20%3CURL%3ENotify%3Ahttp%3A10.24.152.227%3A8080%3Atestpath%3AZHN0YXVkdDpwYXNzd29yZA%3D%3D%3Atestdata%3C%2FURL%3E%0A%20%20%20%20%20%20%20%20%3CPosition%3E1%3C%2FPosition%3E%0A%20%20%20%20%3C%2FSoftKeyItem%3E%0A%3C%2FCiscoIPPhoneText%3E%0A
08-09-2021 12:08 PM
@neblaz, hope you saw this reply above
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide