InvalidAPIKey with C# & Java GitHub examples


#1

Hello.

I am doing a proof of concept for translation using the SYSTRAN io API, but I am stuck getting the unmodifed GitHub examples working on Windows 10 64bit.

I explained how I tested below… any thoughts on what the issue could be or how to test further?

I verified my key on the SysTran Adminstration page where it shows Type=Browser and available for Origins platform.systran.net & api-platform.systran.net

I also did a successful test with key on this websites Reference page
https://platform.systran.net/reference/translation

C# GitHub example

I’m using VS2017 and tested the example unchanged (other than apiKey.txt).

No matter what I try, all the tests fail with this inner exception:
No connection could be made because the target machine actively refused it 51.255.226.125:8904

This is the target URL in the example… is it correct?
https://platform.systran.net:8904

I verfied with the debugger that the key is correctly read from the file, and it appears in the queryParams passed in the GET request.

One oddity I noticed in TranslationApiTests.cs: ClassInit()…

keys.Add("key", key); Configuration.apiKey = keys; Configuration.apiKey = keys; Configuration.apiKey = keys;

Perhaps the keys dictionary is supposed to be stored in 3 different locations instead of the same location thrice?

I tried a long time to get it working, but in the end wasn’t sure about Newtonsoft.JSON package version so thought I would try Java client instead.

Java GitHub example

Again as downloaded other than updating apiKey.txt.

I confirmed I had the current jdk-9.0.4 and apache-maven-3.5.2 installed, but the tests all fail with:

{"error":{"message":"Invalid API key","info":{"statusCode":401},"statusCode":401}}

I confirmed the script was correctly picking up the apiKey.txt file.

The only possible issue I found was this (but I don’t think it’s relevant)…

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for net.systran.platform:translation-api-java-client:jar:1.0.1
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:build-helper-maven-plugin is missing. @ line 64, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[WARNING] The project net.systran.platform:translation-api-java-client:jar:1.0.1 uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html

[Python GitHub example]…

Example run as downloaded other than supplying my key in api_key.txt.
Tested using Python 2.7.

I only dabble in Python, so wasn’t sure if I got the environment right for this, but the nose tests seem to run OK… but the tests themselves all fail with:

TypeError: sequence item 0: expected string, NoneType found
-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): api-platform.systran.net
--------------------- >> end captured logging << ---------------------

The only other warnings are:

SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning
InsecurePlatformWarning
ERROR
test_translation_profile_get (tests.test_translation.TranslationApiTests) ... c:\program files (x86)\python27\lib\site-packages\urllib3-1.22-py2.7.egg\urllib3\util\ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

No idea if these warnings are important or not.


Any tips kindly appreciated.
Indigo.