when I try to login with protocol integration, it gets "401 unauthorization" error.

I tried to implemented login in c++. But it says “401 unauthorization”.

I think something is wrong in header setting.

https://doc.developer.milestonesys.com/html/index.html?base=samples/tcpviewer_sample.html&tree=tree_3.html

this is documentation you provided.

POST /ServerAPI/ServerCommandService.asmx HTTP/1.1

Host: {xprotectserver.company.com}

Authorization: {autogenerated by HTTP library or class applied}

Content-Type: text/xml; charset=utf-8

Content-Length: {number of bytes}

SOAPAction: http://videoos.net/2/XProtectCSServerCommand/Login"

How should I set Authorization header ?

{autogenerated by HTTP library or class applied} doesn’t make sense for me.

the following code is what I coded.

IdHTTP1->Request->Accept = “text/xml”;

IdHTTP1->Request->Host = sServerIP.c_str();

IdHTTP1->Request->BasicAuthentication = false;

IdHTTP1->Request->ContentEncoding = “utf-8”; //in test

IdHTTP1->Request->ContentType = “text/xml; charset=utf-8”; IdHTTP1->Request->ContentLength = sSoap.length();

IdHTTP1->Request->Method = “POST”;

IdHTTP1->Request->Username = sUsername.c_str();

IdHTTP1->Request->Password = sPassword.c_str();

IdHTTP1->Request->UserAgent = “IndyTest”;

IdHTTP1->Request->CustomHeaders->AddValue(“SOAPAction”, sSoapAction.c_str());

TStringStream *pReq = new TStringStream(UnicodeString(sSoap.c_str()), TEncoding::UTF8, true);

TStringStream *pResp = new TStringStream();

IdHTTP1->Post(sURL.c_str(), pReq, pResp);

IdHTTP1->Request->CustomHeaders->Clear();

oss << IdHTTP1->ResponseCode << “\”" << AnsiString(IdHTTP1->Response->ResponseText).c_str() << “\”";

I found a similar question on the forum, please see the Q&A here - https://developer.milestonesys.com/s/question/0D53X00006YUsODSA1/protocol-integration-method-cannot-authenticate-using-soap-401-unauthorized-error