none
Call a SAP ODAT Service with User and Password

    Question

  • Hi,

    Someone has a C # example for me which runs via the Coamndline and calls an SAP ODATA service?
    It should be with user and password in the service ...
    I have read a lot but unfortunately found nothing suitable ...
    Visual Studio is used as of 2012.
    <textarea autocapitalize="off" autocomplete="off" autocorrect="off" class="goog-textarea" dir="ltr" id="contribute-target" name="edit-text" rows="1" spellcheck="false" style="height:auto;padding-right:20px;-ms-overflow-x:auto;-ms-overflow-y:hidden;box-sizing:border-box;" tabindex="0" wrap="SOFT"></textarea>

    Best Regards

    Bernd

    Tuesday, April 18, 2017 2:16 PM

Answers

  • I build a small code sample with Errors...

                System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
                ServiceReference1.Bag _proxy1 = new ServiceReference1.Bag();
                ServiceReference1.BagClassification inputData = new ServiceReference1.BagClassification();
                ServiceReference1.BagClassification outPutData = new ServiceReference1.BagClassification();
    
                cred.UserName = Myusername;
                cred.Password = Mypassword;
    
                _proxy1.PreAuthenticate = true;
                _proxy1.Credentials = cred;
                outPutData = _proxy1.BagClassification(inputData);
    

    The Problem is:

                _proxy1.PreAuthenticate = true;
                _proxy1.Credentials = cred;
                outPutData = _proxy1.BagClassification(inputData);
    
    How can i give SAP the Username and Password?

    • Marked as answer by Bernd Riemke Thursday, April 20, 2017 10:57 AM
    Wednesday, April 19, 2017 10:06 AM

All replies

  • I build a small code sample with Errors...

                System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
                ServiceReference1.Bag _proxy1 = new ServiceReference1.Bag();
                ServiceReference1.BagClassification inputData = new ServiceReference1.BagClassification();
                ServiceReference1.BagClassification outPutData = new ServiceReference1.BagClassification();
    
                cred.UserName = Myusername;
                cred.Password = Mypassword;
    
                _proxy1.PreAuthenticate = true;
                _proxy1.Credentials = cred;
                outPutData = _proxy1.BagClassification(inputData);
    

    The Problem is:

                _proxy1.PreAuthenticate = true;
                _proxy1.Credentials = cred;
                outPutData = _proxy1.BagClassification(inputData);
    
    How can i give SAP the Username and Password?

    • Marked as answer by Bernd Riemke Thursday, April 20, 2017 10:57 AM
    Wednesday, April 19, 2017 10:06 AM
  • I got it...
    Thursday, April 20, 2017 10:57 AM