Hi
I am working on a project that uses Basic authentication scheme to authenticate a user.
I need to call a api in a website.I need to send the username and password in base64 format.
After the header has the host and authentication details, I need to send the request in this format.
=== Request ===
<request client_id="1" client_serial_number="abcded" version="0.1">
<call name="test.reverse">abc</call>
</request>
This is the responce that i should get if all goes well
=== Response ===
<response version="0.1">
<value>cba</value>
</response>
For the header request part, i am using the following code
QXmlStreamReader xml;
void senddata::fetch()
{
xml.clear();
QUrl url
(lineEdit
->text
());
http.setHost(url.host());
http.setUser(username,password);
connectionId = http.get(url.path());
}
QXmlStreamReader xml;
QHttp http;
void senddata::fetch()
{
QString username = "abc";
QString password = "12345";
xml.clear();
QUrl url(lineEdit->text());
http.setHost(url.host());
http.setUser(username,password);
connectionId = http.get(url.path());
}
To copy to clipboard, switch view to plain text mode
I am reading the data here
{
if (resp.statusCode() != 200)
http.abort();
else {
xml.addData(http.readAll());
parseXml();// This funtion has nothing in it as of now
}
}
void senddata::readData(const QHttpResponseHeader &resp)
{
if (resp.statusCode() != 200)
http.abort();
else {
xml.addData(http.readAll());
parseXml();// This funtion has nothing in it as of now
}
}
To copy to clipboard, switch view to plain text mode
Is my code correct? How should i proceed?
How can i parse the response xml and get the data i need?
Bookmarks