I am trying to implement a c++ application that will access an HTTPS server using IServerXMLHTTPRequest.

My current code is:

    CComPtr<MSXML2::IServerXMLHTTPRequest> xmlHttp;
    HRESULT hr = xmlHttp.CoCreateInstance(__uuidof(ServerXMLHTTP));
    hr = xmlHttp->open(_T("POST"),_T("https://someurl.com/somepath"),false);
    hr = xmlHttp->setTimeouts( 100000,
            50000,
            100000,
            100000
            );
    hr = xmlHttp->setOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT, 
                            xmlHttp->getOption(SXH_OPTION_SELECT_CLIENT_SSL_CERT));
    hr = xmlHttp->setRequestHeader(_T("Content-Type"),_T("application/x-www-form-urlencoded"));
    sPostData = ...;
    hr = xmlHttp->send((BSTR)sPostData);

When I try to run the above code, the server returns an 403 (Forbidden) error.

What could be the cause of this? And, what should I do about this?

有帮助吗?

解决方案

I got it working!

For those who might encounter this same problem in the future, you can solve this by specifying in the URL the actual file name and extension instead of just specifying the path.

You can refer to this link: 403 ERROR

Thank you!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top