Created
September 20, 2019 21:11
-
-
Save tcrowe/baf35de0048c0985a914219cd6f66569 to your computer and use it in GitHub Desktop.
Testing IONOS cloud, parsing headers, cURL, node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This approach works. ✅ | |
# The idea is possibly cURL is tolerant to invalid headers. | |
# How to test: | |
# 1. Install cURL https://curl.haxx.se/ | |
# 2. In your terminal copy and paste: | |
curl -v -H 'X-TOKEN: 1234' 'https://cloudpanel-api.ionos.com/v1/servers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This does not work because nodejs cannot parse the headers. 🐛 | |
How to reproduce: | |
1. Install nodejs https://nodejs.org/de/ | |
https://nodejs.org/en/ | |
2a. Try to you use your company's module with node: https://github.com/1and1/oneandone-cloudserver-sdk-nodejs | |
2b. `npm install superagent` and run this script with node | |
*/ | |
const superagent = require("superagent"); | |
const endpointUrl = "https://cloudpanel-api.ionos.com/v1"; | |
const token = "1234"; | |
superagent | |
.get("https://cloudpanel-api.ionos.com/v1/servers") | |
.set("X-TOKEN", token) | |
.type("json") | |
.accept("json") | |
.then(res => console.log("res", res)) | |
.catch(err => console.error("err", err)); // ⬅️⚠️ it will not parse headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the end we discovered that it was node v12 that would not handle these headers. The solution was downgrade to v10.