# Crisp - Setting requestBody for POST calls

**URL:** <https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [November 6, 2019, 8:24pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547 "2019-11-06T20:24:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pankul\_Anil\_Garg](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pankul_anil_garg/32/541_2.png) [@Pankul\_Anil\_Garg](https://community.bloomreach.com/u/Pankul_Anil_Garg)\
**Post date:** [November 6, 2019, 8:24pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/1 "2019-11-06T20:24:32Z")

</div>

Hi, I am having trouble setting requestBody for POST calls when using crisp API. As mentioned in the official document, ExchangeHintBuilder can be used to specify the methodName, requestHeader and requestBody.([https://documentation.bloomreach.com/library/concepts/crisp-api/getting-started.html](https://documentation.bloomreach.com/library/concepts/crisp-api/getting-started.html))

I have to make a call where the content-type is application/x-www-form-urlencoded. I have tried setting this requestHeader but unfortunately this does not work for me.

The same call in POSTMAN works fine when I set the content-type. POSTMAN also appends some temporary request headers like Accept-Encoding, Content-length, UserAgent, Host etc…

Can someone help me understand where am I going wrong?  
I have attached the snippet responsible for this below:  
Resource resource = resourceServiceBroker.resolve(“catalog”,path,  
ExchangeHintBuilder.create()  
.methodName(“POST”)  
.requestHeader(“Accept-Encoding”,“gzip”,“deflate”)  
.requestHeader(“Content-Type”,“application/x-www-form-urlencoded”)  
.requestHeader(“Content-Length”,“24”)  
.requestHeader(“Host”,“[cat.host.org](http://cat.host.org)”)  
.requestBody(“bib=004046593|Equipment0”)  
.build());  
Do I need to append every request header before making the call or are there some headers which will be taken care of by CRISP like content-length? Is there some property that needs to be set when making POST calls that I have missed?

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [November 6, 2019, 8:56pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/2 "2019-11-06T20:56:32Z")

</div>

Hi,

Can you try with `bib%3D004046593%7CEquipment0` instead of the unencoded body data?  
Also, try after removing `Accept-Encoding` and `Content-Length` request headers.  
CRISP uses Spring Framework `RestTemplate` which uses Apache HttpComponents HttpClient. I guess that it should be okay without `Content-Length` in request or HttpClient would set it automatically.

---

<div class="post-metadata">

**Author:** ![Pankul\_Anil\_Garg](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pankul_anil_garg/32/541_2.png) [@Pankul\_Anil\_Garg](https://community.bloomreach.com/u/Pankul_Anil_Garg)\
**Post date:** [November 6, 2019, 9:52pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/3 "2019-11-06T21:52:32Z")

</div>

Hey, I tried with the URLencoded string as well.  
Resource resource = resourceServiceBroker.resolve(“catalog”,path,  
ExchangeHintBuilder.create()  
.methodName(“POST”)  
.requestHeader(“Content-Type”,“application/x-www-form-urlencoded”)  
.requestBody(“bib%3D004046593%7CEquipment0”)  
.build());

This did not work for me

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [November 6, 2019, 11:21pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/4 "2019-11-06T23:21:07Z")

</div>

Sorry, I mean this: `.requestBody("bib=004046593%7CEquipment0")`.  
If this doesn’t work either, could you somehow _monitor_ the http request payload between crisp call and postman call?  
Also, you can see debug logs in HttpClient level by setting these even if it’s really verbose:

```auto
    <Logger name="org.apache.http" level="debug" />
    <Logger name="org.apache.http.wire" level="debug" />

```

---

<div class="post-metadata">

**Author:** ![Pankul\_Anil\_Garg](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pankul_anil_garg/32/541_2.png) [@Pankul\_Anil\_Garg](https://community.bloomreach.com/u/Pankul_Anil_Garg)\
**Post date:** [November 13, 2019, 5:32pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/5 "2019-11-13T17:32:34Z")

</div>

Sorry for the late reply.

```
Resource resource = resourceServiceBroker.resolve("catalog",path,
    ExchangeHintBuilder.create()
        .methodName("POST")
        .requestHeader("Content-Type","application/x-www-form-urlencoded")
        .requestBody("bib=004046593%7CEquipment0")
        .build());

```

The logs from console:

> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “GET /cgi-bin/laptops HTTP/1.1[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “Accept: text/plain, application/json, application/\*+json, _/_[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “Host: [cat.host.org](http://cat.host.org)[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “Connection: Keep-Alive[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “User-Agent: Apache-HttpClient/4.5.6 (Java/1.8.0\_222)[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “Accept-Encoding: gzip,deflate[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \>\> “[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “HTTP/1.1 200 OK[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Date: Wed, 13 Nov 2019 17:11:37 GMT[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Server: Apache[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Pragma: no-cache[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Expires: Fri, 01 Jan 2000 00:00:00 GMT[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Cache-Control: No-Cache, No-Store[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:36 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Keep-Alive: timeout=15, max=100[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Connection: Keep-Alive[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Transfer-Encoding: chunked[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “Content-Type: text/html; charset=ISO-8859-1[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:122] http-outgoing-4 \<\< HTTP/1.1 200 OK  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Date: Wed, 13 Nov 2019 17:11:37 GMT  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Server: Apache  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Pragma: no-cache  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Expires: Fri, 01 Jan 2000 00:00:00 GMT  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Cache-Control: No-Cache, No-Store  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Keep-Alive: timeout=15, max=100  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Connection: Keep-Alive  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Transfer-Encoding: chunked  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.onResponseReceived:125] http-outgoing-4 \<\< Content-Type: text/html; charset=ISO-8859-1  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [MainClientExec.execute:285] Connection can be kept alive for 15000 MILLISECONDS  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “fd1[\r][\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “[\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “[\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “[\n]”  
> [INFO] [talledLocalContainer] 13.11.2019 12:11:37 DEBUG http-nio-8080-exec-9 [Wire.wire:73] http-outgoing-4 \<\< “[\n]”  
> .  
> .  
> .[Response]  
> .  
> .  
> [INFO] [talledLocalContainer] 13.11.2019 12:12:03 DEBUG http-nio-8080-exec-9 [PoolingHttpClientConnectionManager.releaseConnection:341] Connection [id: 4][route: {s}-\>[https://cat.host.org:443](https://cat.host.org:443)] can be kept alive for 15.0 seconds  
> [INFO] [talledLocalContainer] 13.11.2019 12:12:03 DEBUG http-nio-8080-exec-9 [LoggingManagedHttpClientConnection.setSocketTimeout:88] http-outgoing-4: set socket timeout to 0  
> [INFO] [talledLocalContainer] 13.11.2019 12:12:03 DEBUG http-nio-8080-exec-9 [PoolingHttpClientConnectionManager.releaseConnection:348] Connection released: [id: 4][route: {s}-\>[https://cat.host.org:443](https://cat.host.org:443)][total kept alive: 3; route allocated: 1 of 200; total allocated: 3 of 600]

Looks like CRISP makes a GET call rather than a POST call.

HTTP Code from Postman:

> POST /cgi-bin/laptops HTTP/1.1  
> Host: cat.org.umd  
> Content-Type: application/x-www-form-urlencoded  
> User-Agent: PostmanRuntime/7.19.0  
> Accept: _/_  
> Cache-Control: no-cache  
> Postman-Token: 7c33158f-4340-422b-adf3-79889ffd00b5,7a28acb5-de76-4efb-8843-1fcf0b897d38  
> Accept-Encoding: gzip, deflate  
> Content-Length: 24  
> Connection: keep-alive  
> cache-control: no-cache
> 
> bib=004046593|Equipment0

---

<div class="post-metadata">

**Author:** ![Pankul\_Anil\_Garg](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pankul_anil_garg/32/541_2.png) [@Pankul\_Anil\_Garg](https://community.bloomreach.com/u/Pankul_Anil_Garg)\
**Post date:** [November 20, 2019, 2:53pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/6 "2019-11-20T14:53:52Z")

</div>

I am stuck with this from quite some time, any help is really appreciated.

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [November 20, 2019, 3:12pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/7 "2019-11-20T15:12:40Z")

</div>

If you need more direct or speedy support than this community provides I suggest you make contact with Bloomreach or one of our partners. If you are working on an enterprise project you likely already have some level of support. This community can only offer limited support and only so far as the members are able and willing.

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [November 20, 2019, 4:06pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/8 "2019-11-20T16:06:00Z")

</div>

> [@Pankul\_Anil\_Garg](#):
>
> Looks like CRISP makes a GET call rather than a POST call.

That’s weird. What are the version(s)?  
If possible, you can put a debugger at `org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver#resolve(String, Map<String, Object>, ExchangeHint)` method where the `ExchangeHint#methodName()` is read and invocation with either `POST` or `GET` is made.

Regards,

Woonsan

---

<div class="post-metadata">

**Author:** ![Pankul\_Anil\_Garg](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pankul_anil_garg/32/541_2.png) [@Pankul\_Anil\_Garg](https://community.bloomreach.com/u/Pankul_Anil_Garg)\
**Post date:** [December 10, 2019, 5:42pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/9 "2019-12-10T17:42:30Z")

</div>

Thanks so much for that comment. I had created my own resolver and was not handling the POST call within the resolver because of which it was always making a GET call.

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [December 10, 2019, 7:51pm UTC](https://community.bloomreach.com/t/crisp-setting-requestbody-for-post-calls/1547/10 "2019-12-10T19:51:23Z")

</div>

Thanks for the update, Pankul! 🙂
