# Resource requests to the Enterprise Solid Server: Getting 400, Bad Request

**URL:** <https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690>\
**Category:** Build a Solid App\
**Created:** [September 24, 2021, 1:05am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690 "2021-09-24T01:05:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 24, 2021, 1:05am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/1 "2021-09-24T01:05:28Z")

</div>

I’m trying to make resource requests of the Enterprise Solid Server. I have this working (with the different relevant credentials) for the NSS (e.g., with [https://crspybits.solidcommunity.net](https://crspybits.solidcommunity.net)), but I’m getting 400 http responses and “Bad Request” from the ESS.

I’m able to successfully use /token requests with the ESS to refresh my access token.

This uses Swift code, using my own HTTP requests. For reference, the code is here: [GitHub - SyncServerII/ServerSolidAccount: Server-side Solid Pod Account for SyncServerII](https://github.com/SyncServerII/ServerSolidAccount)

I’m attempting to create a new directory/container, and upload a file. In the request below, the access token was successfully refreshed immediately before.

My webid is: [https://pod.inrupt.com/crspybits/profile/card#me](https://pod.inrupt.com/crspybits/profile/card#me)

I’m making a PUT request to:  
[https://pod.inrupt.com/crspybits/32CD8522-D921-43DF-8B3B-8FAC4A71D3E6/13567B1B-1C4C-40C0-AE93-86DC117D04FD.txt](https://pod.inrupt.com/crspybits/32CD8522-D921-43DF-8B3B-8FAC4A71D3E6/13567B1B-1C4C-40C0-AE93-86DC117D04FD.txt)

```auto
Request headers:
["Authorization": "DPoP <snip>", 
"Link": "<http://www.w3.org/ns/ldp#Resource>; rel=\"type\"", 
"Dpop": "<snip>", 
"Host": "pod.inrupt.com", 
"Content-Type": "text/plain"]

```

Response body:

```auto
 {
    "error": {
        
        "code": "400",
        "message": "Bad Request"
    }
}

```

Response headers:

```auto
[AnyHashable("Content-Length"): "90", AnyHashable("Connection"): "keep-alive", AnyHashable("Date"): "Fri, 24 Sep 2021 00:44:13 GMT", AnyHashable("Content-Type"): "application/json", AnyHashable("Strict-Transport-Security"): "max-age=15724800; includeSubDomains"]

```

(This issue is also here: [Resource requests to the Enterprise Solid Server: Getting 400, Bad Request · Issue #5 · SyncServerII/ServerSolidAccount · GitHub](https://github.com/SyncServerII/ServerSolidAccount/issues/5))

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 25, 2021, 3:13am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/2 "2021-09-25T03:13:05Z")

</div>

Well, I’m looking around for issues that could be causing this. One thing I’m noticing is that my DPoP proof does not have an `ath` claim (see [draft-ietf-oauth-dpop-03](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop-03#section-4.3)). Could the ESS require this, but the NSS not?

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 25, 2021, 4:43am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/3 "2021-09-25T04:43:34Z")

</div>

I’ve got an `ath` claim now. No change in the result.

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 25, 2021, 3:53pm UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/4 "2021-09-25T15:53:01Z")

</div>

Well, in further poking around I’ve gotten this to work. I’ve removed the `DPoP` header _entirely_ from the PUT request and this is now working. My test debugging output follows. Somehow the ESS doesn’t require a DPoP proof. And if you give it the request fails, at least with my setup.

> [2021-09-25T15:43:41.329Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:221 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: method: PUT

> [2021-09-25T15:43:41.329Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:222 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: url.host: [pod.inrupt.com](http://pod.inrupt.com)

> [2021-09-25T15:43:41.329Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:223 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: Request headers: Optional([“Content-Type”: “text/plain”, “Authorization”: “DPoP [Snipped-- Was the access token]”, “Host”: “[pod.inrupt.com](http://pod.inrupt.com)”, “Link”: “[http://www.w3.org/ns/ldp#Resource](http://www.w3.org/ns/ldp#Resource); rel="type"”])

> [2021-09-25T15:43:41.330Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:224 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: URL: [https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt](https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt)

> [2021-09-25T15:43:42.033Z] [DEBUG] [SolidCreds+CloudStorage+Extras.swift:145 uploadFile(named:inDirectory:data:mimeType:completion:)] Success Response: Data: Headers: [AnyHashable(“Connection”): “keep-alive”, AnyHashable(“Content-Length”): “0”, AnyHashable(“Date”): “Sat, 25 Sep 2021 15:43:41 GMT”, AnyHashable(“Strict-Transport-Security”): “max-age=15724800; includeSubDomains”, AnyHashable(“Content-Location”): “[https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt](https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt)”, AnyHashable(“Link”): “[http://www.w3.org/ns/ldp#Resource](http://www.w3.org/ns/ldp#Resource); rel="type", [http://www.w3.org/ns/ldp#NonRDFSource](http://www.w3.org/ns/ldp#NonRDFSource); rel="type", \</crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt?ext=shex\>; rel="[Shape Expression Vocabulary](http://www.w3.org/ns/shex#Schema%5C)”, \</powerswitch/crspybits\>; rel="[https://inrupt.com/ns/ess#hasPowerSwitch\](https://inrupt.com/ns/ess#hasPowerSwitch%5C)“, [https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt?ext=description](https://pod.inrupt.com/crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt?ext=description); rel="describedby", \</crspybits/9400A867-9403-489E-B2A3-BF7F604517B3/F311C833-FF7E-4BAA-89D7-78A942B7B1AF.txt?ext=acr\>; rel="[http://www.w3.org/ns/solid/acp#accessControl\](http://www.w3.org/ns/solid/acp#accessControl%5C)”, [http://www.w3.org/ns/solid/acp#Read](http://www.w3.org/ns/solid/acp#Read); rel="[http://www.w3.org/ns/solid/acp#allow\](http://www.w3.org/ns/solid/acp#allow%5C)“, [http://www.w3.org/ns/solid/acp#Write](http://www.w3.org/ns/solid/acp#Write); rel="[http://www.w3.org/ns/solid/acp#allow\](http://www.w3.org/ns/solid/acp#allow%5C)”"]

> Status Code: 201

> Test Case ‘GeneralTests.testUploadNewFile\_NewDirectory’ passed (1.634 seconds)

And so you can see the evidence of the successful creation of the new folder in the Pod browser:

 ![Screen Shot 2021-09-25 at 9.54.26 AM](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/3/3e04dc34854039fba036ebf5e2ed55187f58a4b8.png)

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 26, 2021, 12:52am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/5 "2021-09-26T00:52:51Z")

</div>

One more fact: If I also don’t use the DPoP header with resource requests to [https://crspybits.solidcommunity.net/](https://crspybits.solidcommunity.net/) it fails. It seems a difference between CSS and ESS is that CSS needs the DPoP proof where ESS doesn’t.

---

<div class="post-metadata">

**Author:** ![acoburn](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/acoburn/32/79_2.png) [@acoburn](https://forum.solidproject.org/u/acoburn)\
**Post date:** [September 27, 2021, 4:36pm UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/6 "2021-09-27T16:36:21Z")

</div>

The DPoP header is a red herring. The problem is the use of your link header. Try using `<http://www.w3.org/ns/ldp#NonRDFSource>; rel="type"` when creating text resources.

In ESS, DPoP is required when the client uses DPoP when it first requests a token from the identity provider. If the client does not use DPoP at the `token_endpoint`, then DPoP is not required because the token will not be bound to a client-managed keypair. Generally, you should be using DPoP, especially if you are sending tokens to multiple Pod servers.

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 28, 2021, 2:30am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/7 "2021-09-28T02:30:26Z")

</div>

Thanks for that. I changed the code to use this for the link header, signed the user in again, generated a new access token, and retried the request. Unfortunately, no change.

> [2021-09-28T02:22:23.874Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:221 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: method: PUT

> [2021-09-28T02:22:23.874Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:222 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: url.host: [pod.inrupt.com](http://pod.inrupt.com)

> [2021-09-28T02:22:23.874Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:223 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: Request headers: Optional([“Dpop”: “[snip]”, “Link”: “[http://www.w3.org/ns/ldp#NonRDFSource](http://www.w3.org/ns/ldp#NonRDFSource); rel="type"”, “Content-Type”: “text/plain”, “Authorization”: “DPoP [snip]”, “Host”: “[pod.inrupt.com](http://pod.inrupt.com)”])

> [2021-09-28T02:22:23.874Z] [DEBUG] [SolidCreds+CloudStorage+Requests.swift:224 request(path:httpMethod:body:headers:accessTokenAutoRefresh:completion:)] Request: URL: [https://pod.inrupt.com/crspybits/62DB7A4F-2281-47D0-9DB3-A60D2FD870F1/1706F328-4C0A-485E-8F7B-09ACD1164433.txt](https://pod.inrupt.com/crspybits/62DB7A4F-2281-47D0-9DB3-A60D2FD870F1/1706F328-4C0A-485E-8F7B-09ACD1164433.txt)

> [2021-09-28T02:22:24.475Z] [DEBUG] [SolidCreds+CloudStorage+Extras.swift:154 uploadFile(named:inDirectory:data:mimeType:completion:)] Failure Response: Data: {  
> “error”: {

```
    "code": "400",
    "message": "Bad Request"
}

```

}

> Headers: [AnyHashable(“Connection”): “keep-alive”, AnyHashable(“Content-Type”): “application/json”, AnyHashable(“Content-Length”): “90”, AnyHashable(“Strict-Transport-Security”): “max-age=15724800; includeSubDomains”, AnyHashable(“Date”): “Tue, 28 Sep 2021 02:22:24 GMT”]

Status Code: 400; error: badStatusCode

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [September 30, 2021, 11:55am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/8 "2021-09-30T11:55:55Z")

</div>

I’ve refactored this code and the resource access code I’m using now is in: [GitHub - crspybits/SolidResourcesSwift: Make resource requests to a Solid Pod in the Swift language](https://github.com/crspybits/SolidResourcesSwift)

---

<div class="post-metadata">

**Author:** ![crspybits](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/crspybits/32/2857_2.png) [@crspybits](https://forum.solidproject.org/u/crspybits)\
**Post date:** [October 20, 2021, 3:08am UTC](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/9 "2021-10-20T03:08:15Z")

</div>

Summary: While I can get resource requests working with the ESS, I cannot do so with a DPoP header present. This is a problem for me because [in my testing, the NSS seems to require the DPoP header for resource requests](https://forum.solidproject.org/t/resource-requests-to-the-enterprise-solid-server-getting-400-bad-request/4690/5), and I need a method that works generally across all Solid servers (e.g., for both the ESS and NSS).
