i have made some changes to my code
I first need to get the Client id and the serial no
//This is how i need to send the request
=== Request ===
<request version="0.1">
<call name="client.create">
<client>
<kind>MOBILE</kind>
<name>API Test suite 7936</name>
</client>
</call>
</request>
//This is what i will get, if everything goes well
=== Response ===
<response version="0.1">
<client id="1">
<name>API Test suite 7936</name>
<kind>MOBILE</kind>
<serial_number>a09b4d3b-08b7-4cdf-bf3c-a5a8fb27ee1f</serial_number>
<added_on>2009-06-25 12:33:49.182287</added_on>
<enabled>True</enabled>
</client>
</response>
//This is how i need to send the request
=== Request ===
<request version="0.1">
<call name="client.create">
<client>
<kind>MOBILE</kind>
<name>API Test suite 7936</name>
</client>
</call>
</request>
//This is what i will get, if everything goes well
=== Response ===
<response version="0.1">
<client id="1">
<name>API Test suite 7936</name>
<kind>MOBILE</kind>
<serial_number>a09b4d3b-08b7-4cdf-bf3c-a5a8fb27ee1f</serial_number>
<added_on>2009-06-25 12:33:49.182287</added_on>
<enabled>True</enabled>
</client>
</response>
To copy to clipboard, switch view to plain text mode
My code to send the request is this
void MainWindow::fetch()
{
string.append(":");
string.append("12345");
QString converted
= string.
toBase64();
xml.clear();
QUrl url
("http://something/");
http.setHost(url.host(),url.port(80));
http.setUser(converted);
connectionId = http.get(url.path());
sendrequest();
http.post(url.path(),xmlrequest);
}
void MainWindow::sendrequest()
{
root.setAttribute("version", "0.1");
doc.appendChild(root);
tag.setAttribute("name","teci.client.create");
root.appendChild(tag);
tag.appendChild(tag1);
QDomText t
= doc.
createTextNode("MOBILE");
tag2.appendChild(t);
tag1.appendChild(tag2);
t = doc.createTextNode("API Test suite 7936");
tag3.appendChild(t);
tag1.appendChild(tag3);
xmlrequest.append(doc.toString());
qDebug() << xmlrequest.data();
}
void MainWindow::fetch()
{
QByteArray string ("username");
string.append(":");
string.append("12345");
QString converted = string.toBase64();
xml.clear();
QUrl url("http://something/");
http.setHost(url.host(),url.port(80));
http.setUser(converted);
connectionId = http.get(url.path());
sendrequest();
http.post(url.path(),xmlrequest);
}
void MainWindow::sendrequest()
{
QDomDocument doc;
QDomElement root = doc.createElement("request");
root.setAttribute("version", "0.1");
doc.appendChild(root);
QDomElement tag = doc.createElement("call");
tag.setAttribute("name","teci.client.create");
root.appendChild(tag);
QDomElement tag1 = doc.createElement("client");
tag.appendChild(tag1);
QDomElement tag2 = doc.createElement("kind");
QDomText t = doc.createTextNode("MOBILE");
tag2.appendChild(t);
tag1.appendChild(tag2);
QDomElement tag3 = doc.createElement("name");
t = doc.createTextNode("API Test suite 7936");
tag3.appendChild(t);
tag1.appendChild(tag3);
xmlrequest.append(doc.toString());
qDebug() << xmlrequest.data();
}
To copy to clipboard, switch view to plain text mode
output i am getting is this
<request version="0.1" >
<call name="client.create" >
<client>
<kind>MOBILE</kind>
<name>API Test suite 7936</name>
</client>
</call>
</request>
Received error during HTTP fetch.
<request version="0.1" >
<call name="client.create" >
<client>
<kind>MOBILE</kind>
<name>API Test suite 7936</name>
</client>
</call>
</request>
Received error during HTTP fetch.
To copy to clipboard, switch view to plain text mode
What should I do to get the program working?
The request is according to the specification. What am i missing here?
Bookmarks