TDI Sockets bad request - c++

I am trying to write requests to the server from the kernel using this lab
TDI based socket interface
Why is it that
when I TDISend the request for the address HTTPS://server.com:443/api/
I get this error:
Status 400
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>cloudflare</center>
</body>
</html>
when I TDISend the request for the address HTTP://server.com:80/api/
I get this error:
Status 301
Moved Permanently.

Related

Handle camunda start process errors

I have a process that fails on the first task because of data validation. I want the task to fail. My problem is that when I start the Camunda process with the REST API I receive an HTML page produced by the underlying Tomcat. How can I get a comprehensive JSON response from the API instead of an HTML ?
I'm running Camunda CE 7.9.
I'm deploying a spring boot war on the Camunda Tomcat provided by Camunda.
Response:
<!doctype html>
<html lang="fr">
<head>
<title>État HTTP 500 – Internal Server Error</title>
<style type="text/css">
[...]
</style>
</head>
<body>
<h1>État HTTP 500 – Internal Server Error</h1>
<hr class="line" />
<p><b>Type</b> Rapport d''exception</p>
<p><b>message</b> company.service.RestException: message: Agent XXX not found</p>
<p><b>description</b> Le serveur a rencontré une erreur interne qui l''a empêché de satisfaire la requête.</p>
<p><b>exception</b></p>
<pre>org.jboss.resteasy.spi.UnhandledException: company.service.RestException: message: Agent XXX not found
[...]
Thank you
You were most likely using the wrong endpoint URL.

Reverse geolocation. Loading api/geocode I get SyntaxError: Unexpected token ':'. Parse error

This is​​ a single script.php only to load data.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
</head>
<body>
<div id="location">
<script src="https://maps.googleapis.com/maps/api/geocode/json?latlng=42.149247222222,24.752305555556&key=My-enabled-key-here">
</script>
</div>
</body>
</html>
In Mac Safari I get I get `SyntaxError: Unexpected token ':'. Parse error.
Several data is loaded I see it in Safari debugger starting in:
but I cannot use it because of that error message.
In Chrome and Opera I get Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type application/json.
Reading some old questions I added
<?php header('Access-Control-Allow-Origin: http://example.com') ?>
and then replaced by
<?php header('Access-Control-Allow-Origin: *') ?>
as the first line but nothing changed.
From Google side: Key restrictions
-> Application restrictions: none.
-> API restrictions: yes (key is accepted for 4 APIs, one of them is Geocoding API
What's wrong here?
Since you are making a Geocoding web service request in the client-side (front-end) that's why you are getting the Cross-origin blocking error (CORB). Web service requests are meant to be executed server side.
Note that if you intend to use Geocoding in client-side, the JavaScript API has a Geocoding Service (which prevents the CORB issue). Please refer to this guide: https://developers.google.com/maps/documentation/javascript/geocoding
Hope this helps!

GraphQL on AWS lambda: The request could not be satisfied. How to solve 403 error?

I have deployed an GraphQL API to AWS Lambda using the Zappa Framework. If I do a request from my local machine to the local server version like this everything works fine:
import requests
url = 'http://127.0.0.1:8000/graphql'
token = '...'
headers = {'Authorization': 'JWT '+token}
query = { 'query' : '{ ...}
r = requests.get(url=url, json=query, headers=headers)
print (r.text)
If I do the same request to my AWS URL https://xyz.execute-api.eu-central-1.amazonaws.com/production/graphql it yields the following error:
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
It should be noted that the GraphiQL view works properly under the mentioned AWS URL where I can do my queries without any problems. Am I missing something to get it going from other devices machine to machine?
Cheers!

NTLM with Postman shows "JSONError | Unexpected token '<' at 1:1 "

I have script to do API automation by fetching data from CSV file and comparing JSON response with the data in CSV file in POSTMAN. I have 12 scenarios/ iterations to verify and each scenario sends more than 20 data picking from CSV file and from JSON response compared more than 10 data. Everything is working fine.
Now Security feature implemented in code, so I have to send the request and Automate the script with ID/PWD. So I used NTML authentication with ID and PWD.
When I run the script with runner, initial two iteration gives perfect response and script passed, then from 3rd iteration all script failed and not getting response. In response it says Data unavailable when I checked in postman console it shows below details.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
<h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>
</body>
</html>
What could be the reason and any solution to solve this.
Screen short
Used NTLM Authentication [BETA] authorization option with ID/PWD
Here are the details for pass scenario
Request Headers:
content-type:"application/json"
cache-control:"no-cache"
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:"xxxxxx"
accept-encoding:"gzip, deflate"
content-length:599
authorization:"NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5K0DvDIPzQ09CFXWo0Q=="
Request Body:
Response Headers:
transfer-encoding:"chunked"
content-type:"application/json; charset=utf-8"
location:"xxxxxx/api/rate/zzz"
server:"Kestrel"
persistent-auth:"true"
date:"Wed, 06 Jun 2018 13:40:05 GMT"
Response Body:
rate:5
retailRateAttributes:
error:null
Here are the details of Failed scenario
Request Headers:
content-type:"application/json"
cache-control:"no-cache"
authorization:"NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5K0DvDIPzQ09CFXWo0Q=="
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:""xxxxxx""
accept-encoding:"gzip, deflate"
content-length:599
Request Body:
Response Headers:
content-type:"text/html"
server:"Microsoft-IIS/10.0"
www-authenticate:
0:"Negotiate"
1:"NTLM"
date:"Wed, 06 Jun 2018 13:40:05 GMT"
content-length:"1293"
Response Body:
While Postman errors are not the most descriptive, this error typically occurs because your API endpoint does not exist. You may want to check that you are correctly calling the appropriate endpoint
You say that the two first iterations work fine but when you get to the third iteration, get the error. That sounds like the auth/token/session expired.
I got the Postman error message
JSONError: Unexpected token '<' at 1:1<!doctype html>^ today.
I realized that the problem (in my case) was that I tried to access an API that
I had written myself, but forgotten to upload. - Thus, I tried to call an API
that did not exist. (!)
As soon as I uploaded the API, the error went away.

icloud caldav returning 401 unauthorized

Was using caldav to access icloud calendar, it was working fine. Today, all the requests in my postman collection started to get 401 from caldav.icloud.com
I am accessing my own personal account to test, double checked my password hundred times, still not working.
Request:
PROPFIND / HTTP/1.1
Host: caldav.icloud.com
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: 39b27b44-0a6f-b351-540f-f9446df618d0
<propfind xmlns='DAV:'>
<prop>
<current-user-principal/>
</prop>
</propfind>
Response was:
401 unauthorized
Header:
Connection →keep-alive
Content-Length →141
Content-Type →text/html;charset=utf-8
Date →Fri, 30 Jun 2017 14:23:34 GMT
Server →AppleHttpServer/2f080fc0
Strict-Transport-Security →max-age=31536000; includeSubDomains
WWW-Authenticate →x-mobileme-authtoken realm="MMCalDav", basic realm="MMCalDav"
X-Apple-Request-UUID →95e3a459-10b1-4d0a-a3ae-73f29b569481
X-Responding-Server →caldav:44101701:pv38p41ic-ztdg01080801:8001:17D70:375f9f89bf
X-Transaction-Id →95e3a459-10b1-4d0a-a3ae-73f29b569481
access-control-expose-headers →X-Apple-Request-UUID, Via
via →icloudedge:br30p01ic-zteu01122201:7401:17D30:Berlin
Body:
<html>
<head>
<title>Unauthorized</title>
</head>
<body>
<h1>Unauthorized</h1>
<p>You are not authorized to access this resource.</p>
</body>
</html>
Any ideas?
You cannot do a 3rd party login into iCloud with your regular login/password anymore (DAV, IMAP, etc). Since June 15, 2017 you need an "App specific password".
This page describes how to generate one: Using app-specific passwords. From that page:
Sign in to your Apple ID account page.
In the Security section, click Generate Password below App-Specific Passwords.
Follow the steps on your screen.