Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:28:03+00:00 2026-06-11T13:28:03+00:00

I’m trying to send a JSON query to a web service and I continue

  • 0

I’m trying to send a JSON query to a web service and I continue to get internal server errors as a response to the query.

Here is what I’m trying to send:

POST /api/1.7/webservice.asmx HTTP/1.1
Host: www.superService.com
User-Agent: My app name v0.1
X-Custom-User-Agent: My app name v0.1
Content-Type: application/json
Content-Length:81

{"method":"AuthenticatePlain","loginName":"username@domain.com","password":"mypass"}

This is supposed to be sent to https://www.superService.com/api/1.7/ssapi.asmx

In preparing the QNetworkRequest, what method is used to insert the line

POST /api/1.7/webservice.asmx HTTP/1.1?

Is the complete header contained in the QNetworkRequest object?
Should the JSON data be in the QNetworkRequest object or is that added to the post as the second argument in the QNetworkAccessManager::post() method?

Here is my current code in the on_btnLogin_clicked() slot:

connect(m_qnam, SIGNAL(finished(QNetworkReply*)),
                 this, SLOT(handleNetworkData(QNetworkReply*)));
    connect(m_qnam,SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
                 this, SLOT(handleSSLErrors(QNetworkReply*)));

    QString baseString = "";
    baseString.append(QString("POST /api/1.7/webservice.asmx HTTP/1.1\r\n").toUtf8());  
    baseString.append(QString("www.superService.com\r\n").toUtf8());
    baseString.append(QString("User-Agent: My app name v0.1\r\n").toUtf8());
    baseString.append(QString("X-Custom-User-Agent: My app name v0.1\r\n").toUtf8());
    baseString.append(QString("Content-Type: application/json\r\n").toUtf8());

    QString jsonString = QString("{");
    jsonString.append("\"method\":");
    jsonString.append("\"AuthenticatePlain\"");
    jsonString.append(",\"loginName\":");
    jsonString.append("\"username@domain.com\"");
    jsonString.append(",\"password\":");
    jsonString.append("\"mypass\"");
    jsonString.append("}");

    QByteArray json = jsonString.toUtf8();

    baseString.append(QString("Content-Length:").toUtf8());
    baseString.append(QString::number(json.length()));
    baseString.append("\r\n").toUtf8();
    baseString.append(QString("\r\n").toUtf8());
    baseString.append(json);

    request = QNetworkRequest(QUrl("https://www.superService.com/api/1.7/ssapi.asmx"));
    request.setRawHeader()


    qDebug() << "Base String: "<< baseString;


    m_qnam->post(request,baseString.toUtf8());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:28:04+00:00Added an answer on June 11, 2026 at 1:28 pm

    This is not the right way to write your HTTP request. The following piece of code is more correct :

    connect(m_qnam, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleNetworkData(QNetworkReply*)));
    connect(m_qnam,SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(handleSSLErrors(QNetworkReply*)));
    
    // Build your JSON string as usual
    QByteArray jsonString = "{\"method\":\"AuthenticatePlain\",\"loginName\":\"username@domain.com\",\"password\":\"mypass\"}";
    
    // For your "Content-Length" header
    QByteArray postDataSize = QByteArray::number(jsonString.size());
    
    // Time for building your request
    QUrl serviceURL("https://www.superService.com/api/1.7/ssapi.asmx");
    QNetworkRequest request(serviceURL);
    
    // Add the headers specifying their names and their values with the following method : void QNetworkRequest::setRawHeader(const QByteArray & headerName, const QByteArray & headerValue);
    request.setRawHeader("User-Agent", "My app name v0.1");
    request.setRawHeader("X-Custom-User-Agent", "My app name v0.1");
    request.setRawHeader("Content-Type", "application/json");
    request.setRawHeader("Content-Length", postDataSize);
    
    // Use QNetworkReply * QNetworkAccessManager::post(const QNetworkRequest & request, const QByteArray & data); to send your request. Qt will rearrange everything correctly.
    QNetworkReply * reply = m_qnam->post(request, jsonString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.