2

I am using sp2013. I have created some workflow. Is it possible to access some webmethod in a webservice from my workflow? The webservice is on another environment and has a username/password to authenticate.

I am using SharePoint Designer Workflows.

2
  • Are you using designer workflows or Visual studio workflows?
    – Aanchal
    Commented Jun 6, 2014 at 8:53
  • Im using SPD...
    – Ola
    Commented Jun 6, 2014 at 11:26

2 Answers 2

1

You can use Call HTTP Web Service action for this and pass your username password along with request.

There are some articles about How to work with web service using “Call HTTP Web Service” action in SharePoint Designer 2013, you can have a look at them.

http://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/

http://rogereriksen.wordpress.com/2013/05/24/create-a-sharepoint-site-using-rest-in-workflow-with-sharepoint-designer/

http://blogs.msdn.com/b/sharepointdesigner/archive/2012/09/05/how-to-work-with-web-service-using-call-http-web-service-action.aspx

Otherwise you can check if you can use following activity in 2013 also as it is valid in 2010.

http://ilovesharepoint.codeplex.com/wikipage?title=Call%20a%20Web%20Service%20Action

1
  • I know this topic is old, but it still comes up in searches, so: None of the links you specified answer the basic question of how do you send authentication strings using the Call HTTP Web Service action in a SPD workflow. I've been fighting that one myself, and have yet to find an answer.
    – Barry
    Commented Sep 20, 2017 at 20:08
1

I'd like to contribute exactly how to add http basic authentication to your SharePoint workflow call.

While designing your Workflow build a dictionary to hold your request header. In this dictionary add one item of type String with the Name "Authorization".

Now you need your value. For the value explanation I'll just quote wikipedia:

The Authorization field is constructed as follows:

The username and password are combined with a single colon. (:)
The resulting string is encoded into an octet sequence.
The resulting string is encoded using a variant of Base64.
The authorization method and a space (e.g. "Basic ") is then prepended to the encoded string, separated with a space.

For example, if the browser uses Aladdin as the username and OpenSesame as the password, then the field's value is the base64-encoding of Aladdin:OpenSesame, or QWxhZGRpbjpPcGVuU2VzYW1l. Then the Authorization header will appear as:

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Source: https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side

So in the example above your Value for the Authorization would be: "Basic QWxhZGRpbjpPcGVuU2VzYW1l"

Note that you have to provide the already Base64 encrypted Username:Password Segment. You cannot send it in Plain Text.

...

In order to encode my Username:Password I used a bit of C# Code

public static string Base64Encode(string plainText)
{
    var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
    return System.Convert.ToBase64String(plainTextBytes);
}

public static string CreateBasicHTTPAuthorizationString(string username, string password)
{
    string encodedPart = username + ":" + password;
    encodedPart = Base64Encode(encodedPart);
    string authorizationString = "Basic " + encodedPart;
    return authorizationString;
}

Original Source: https://stackoverflow.com/questions/11743160/how-do-i-encode-and-decode-a-base64-string

How you handle the encoding is up to you.

...

Back to the task at hand: Now that we have our Request Header dictionary containing our Authorization we just add it to our Call Http Web Service command. Right click the command in Workflow Designer and choose Properties... There you just add our dictionary under RequestHeaders.

Good Luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.