Spring RestTemplate needs header UserAgent


#1

Hi Squidex Team,

we have a Java Sevice which do the calls to Squidex API via REST. This doesn’t work out of the box. After debugging the Code we see that user agent header is needed.

Do you know this problem and can you resolve it? As workaround we add this header to the request.

Best regards,
Jens Lehmann


#2

Hi Jens,

who needs the user agent? Squidex API?


#3

Hi Sebastian,

Cloudflare I think.

Best regards,
Jens


#4

I just tested it with fiddler:

GET https://cloud.squidex.io/api/content/squidex-website/blog?$top=10 HTTP/1.1
Authorization: Bearer ...
Host: cloud.squidex.io

#5

Hi Sebastian,

with Chrome RestClient and CURL we have also no problems, but in our Apllication using Spring RestTemplate.

Best regards,
Jens


#6

Can you debug it with Fiddler and send me the request via DM?


#7

We had the same issue with RestTemplate, so we decided it’s a bit funny, but changed the user-agent string to “not java” and everything works since then. So, if you put a header like this:

curl -H "User-Agent: Java/1.8.0_131" ...

you will get in response:

...
<title>Access denied | cloud.squidex.io used Cloudflare to restrict access</title>
...
<div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="what_happened">What happened?</h2>
            <p>The owner of this website (cloud.squidex.io) has banned your access based on your browser's signature (49572abeec7a8c7c-ua21).</p>
          </div>


        </div>
...

#8

Interesting, I have not blocked it by myself.


#9

I have found the setting in cloudflare. It seems that Java is used a lot by spammers :wink:


#10

Cool, that means we can finally remove our custom User-Agent: not java :+1: