# WCF API testing in Postman

**URL:** <https://community.postman.com/t/wcf-api-testing-in-postman/75078>\
**Category:** Help Hub\
**Tags:** tests, authentication\
**Created:** [February 7, 2025, 2:46pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078 "2025-02-07T14:46:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 2:46pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/1 "2025-02-07T14:46:58Z")

</div>

@danny-dainton

Hi again Danny. Forgive the crude copy/paste job

I was wondering if anyone has had experience testing a WCF API with a SOAP Action, using Postman ?  
This is also using OAuth2

I am trying to test using Postman but keep running up against a 401.  
This is the same when I try SOAPUI.  
I wrote a quick test in .Net using HttpClient and get the expected Response.

I am trying to create a collection to give to Client’s, rather than writing an app that has to be maintained etc…

any hints or help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [February 7, 2025, 2:50pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/2 "2025-02-07T14:50:36Z")

</div>

Hey @ConnAtBrady 👋

Are you able to share a redacted copy of the HttpClient code that you created?

There might be some clues in there about any differences between those requests.

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 2:58pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/3 "2025-02-07T14:58:28Z")

</div>

hi Danny, sure

**Token Request:**

```auto
            using var client = new HttpClient();
            // Request token
            var tokenRequest = new HttpRequestMessage(HttpMethod.Post, tokenEndpoint);
            tokenRequest.Content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("grant_type", "client_credentials"),
                new KeyValuePair<string, string>("client_id", clientId),
                new KeyValuePair<string, string>("client_secret", clientSecret)
            });

            var tokenResponse = await client.SendAsync(tokenRequest);
            tokenResponse.EnsureSuccessStatusCode();

            string tokenContent = await tokenResponse.Content.ReadAsStringAsync();
            return Newtonsoft.Json.Linq.JObject.Parse(tokenContent)["access_token"]!.ToString();

```

**API Request:**

```auto
            using var client = new HttpClient();
            var apiRequest = new HttpRequestMessage(HttpMethod.Get, apiEndpoint);
            apiRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
            apiRequest.Headers.Add("SOAPAction", soapAction);
            apiRequest.Headers.Add("ContentType", "application/xml");
            apiRequest.Headers.Add("Accept", "text/xml");
            apiRequest.Content = new StringContent(soapEnvelope, Encoding.UTF8, "text/xml");

            var apiResponse = await client.SendAsync(apiRequest);
            apiResponse.EnsureSuccessStatusCode();

            return await apiResponse.Content.ReadAsStringAsync();

```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [February 7, 2025, 3:03pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/4 "2025-02-07T15:03:56Z")

</div>

Is the Token Request successful?

Are you using the OAuth helper in the request to get the token or is that a standalone request?

Are you storing that token value in your Postman response as a variable, to reuse in the other request?

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 3:06pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/5 "2025-02-07T15:06:39Z")

</div>

for basics to get a working solution i am generating the token in postman, then putting that into the request

with the HTTPClient code, yes I generate a valid token

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [February 7, 2025, 3:11pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/6 "2025-02-07T15:11:36Z")

</div>

So for the first part in Postman, that successfully generates the token from the request.

Then you’re seeing a 401 from the second request, with that newly created token?

Are you using the Bearer Token helper in the second request or manually added an `Authorization:Bearer XXXX` request header?

Apologies for all the questions, I can’t see what you have in front of you so I’m trying to build up a picture in my mind.

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 3:16pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/7 "2025-02-07T15:16:45Z")

</div>

no apologies necessary

for now i am doing the second part, and add the generated token, of course passing a parameter. but get it working first

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/f/2/f23cd99979f8fae107853abee5b638bb848616b9.png)

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 3:19pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/8 "2025-02-07T15:19:41Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/9/b9385b86f67ab4b71792ad990103fe901d8190ff.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [February 7, 2025, 3:47pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/9 "2025-02-07T15:47:24Z")

</div>

Could you try setting storing/copying the valid token, set the Auth Type to “No Auth” and then manually adding an `Authorization` Request Header instead?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/c/4c7f148e6781afd4a1b08404c1cf48a626a13f76.png)

I just wanted to check it not something weird happening with that Auth Helper.

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 7, 2025, 4:10pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/10 "2025-02-07T16:10:46Z")

</div>

> [@danny-dainton](#):
>
> Authorization

hi Danny, still the same.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/8/d/8d9454cc954f4ad70da2ac9819dbac7e17e8040b.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/8/98009c3c01d0c5a3241c6caa0d199c1dc6479bf2.png)

I think i need to go back to scratch and start again, and drag a developer in to explain this in depth. i have a set of thumb screws somewhere 😃

But thats a problem for Monday 😃

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 10, 2025, 11:08am UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/11 "2025-02-10T11:08:50Z")

</div>

Hi Danny, why are weekends never long enough 😃

Our developers have advised attaching a server Certificate for this issue, but still getting issues.

So I am using a .pfx certificate and now being advised to try a PEM file.

Beginning to think this is following the old Confucius analogy of throw enough at the wall, and some might stick 😛

Would you have a recommended approach to attaching certificates ?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [February 10, 2025, 11:39am UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/12 "2025-02-10T11:39:55Z")

</div>

You can find more information about how this can be done via our Docs site - Hopefully that give you enough to have a crack at it on your side 🙏

> **[Add and manage CA and client certificates in Postman | Postman Docs](https://learning.postman.com/docs/sending-requests/authorization/certificates/)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![ConnAtBrady](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@ConnAtBrady](https://community.postman.com/u/ConnAtBrady)\
**Post date:** [February 17, 2025, 3:35pm UTC](https://community.postman.com/t/wcf-api-testing-in-postman/75078/13 "2025-02-17T15:35:12Z")

</div>

Hi again Danny, I won’t say happy Monday, the only Monday that make us happy is a Bank Holiday Monday 😃

So I created a small .Net app to interact with our API and then ran it with Fiddler polling for network traffic.  
From this, I think it looks like the problem lies with how WCF authenticates, as well as OAUTH2, i.e.

1. The first request sends the SOAP envelope but gets 401 Unauthorized because the server requires authentication.
2. The second request is a simple POST that also gets 401, but this triggers the authentication mechanism.
3. The third request includes the correct Negotiate token and JWT—this is why it succeeds with 200 OK.

So I need to find out how I can get Postman to handle this sequence, hopefully without writing a script to do so.

Is this possible ? Even with a script, if not possible through the UI ?
