Error occurred on routing_api __get _route response status code 403 - python-3.x

I'd like to compute the travel time between two points. So I use the RoutingApi from herepy library (as reported in the example at https://github.com/abdullahselek/HerePy/blob/master/examples/routing_api.py):
from herepy import (
RoutingApi,
RouteMode,
MatrixRoutingType,
MatrixSummaryAttribute,
RoutingTransportMode,
RoutingMode,
RoutingApiReturnField,
RoutingMetric,
RoutingApiSpanField,
AvoidArea,
AvoidFeature,
Avoid,
Truck,
ShippedHazardousGood,
TunnelCategory,
TruckType,
)
routing_api = RoutingApi(api_key="my_key")
response = routing_api.truck_route(
waypoint_a=[lat_a, lon_a],
waypoint_b=[lat_b, lon_b],
modes=[RouteMode.truck, RouteMode.fastest],
)
print(response.as_dict())
Though, even if my api key is valid and "enabled" on the HERE developer platform, I get the following error message:
HEREError: Error occurred on routing_api __get _route response status code 403
Can anyone explain to me why is this happening and how to solve that? Thank you in advance.

The issue is with coordinates.
Looking at the example at https://github.com/abdullahselek/HerePy/blob/master/examples/routing_api.py
if you try:
response = routing.car_route(waypoint_a=[41.9798, -87.8801], waypoint_b=[41.9043, -87.9216], modes=[herepy.RouteMode.car, herepy.RouteMode.fastest])
print(response.as_dict())
it should work.

Related

bioMart Package error: error in function useDataset

I am trying to use the biomaRt package to access the data from Ensembl, however I got error message when using the useDataset() function. My codes are shown below.
library(httr)
listMarts()
ensembl = useMart("ENSEMBL_MART_ENSEMBL")
listDatasets(ensemble)
ensembl = useDataset("hsapiens_gene_ensembl",mart = ensemble)
When I type useDataset function i got error message like this:
> ensembl = useDataset("hsapiens_gene_ensembl",mart = ensembl)
Ensembl site unresponsive, trying asia mirror
Error in textConnection(text, encoding = "UTF-8") :
invalid 'text' argument
and sometimes another different error message showed as:
> ensembl = useDataset("hsapiens_gene_ensembl",mart = ensembl)
Ensembl site unresponsive, trying asia mirror
Error in textConnection(bmResult) : invalid 'text' argument
it seems like that the mirror automatically change to asia OR useast OR uswest, but the error message still shows up over and over again, and i don't know what to do.
So if anyone could help me with this? I will be very grateful for any help or suggestion.
Kind regards Riley Qiu, Dongguan, China

Binance API in python APIError(code=-1121): Invalid symbol

I am trying to code a binance Buy function. However the code
from binance.enums import *
order = client.create_order(symbol='DOGEUSDT', side = 'BUY', type = 'MARKET', quantity = 475, timeInForce='GTC')
this code outputs > APIError(code=-1121): Invalid symbol.
Also, for the same symbol,
print(client.get_symbol_info(symbol="DOGEUSDT"))
ouptuts > None
The symbol DOGEUSDT exists is the orderbook. https://api.binance.com/api/v3/ticker/bookTicker
I dont know why the same symbol I get from binance is invalid.
Are you using the testnet? I had the same error, however when I removed testnet=True from the client initialization the error was resolved.
two things can happen
client.API_URL = https://testnet.binance.vision/api
in that case change it to
https://api.binance.com/api
Client(api_key, secret_key, testnet=True)
in that case change testnet=False or delete it

AwesomeWM: Error when initialising a theme

I've currently started using the AwesomeWM and started configuring it. I struggle at theming: whenever I try to change the theme, I get this error message:
https://i.stack.imgur.com/vAbuW.png
It tells me that the error is on the line 553/554, but if I don't adjust any themes, they work without any errors.
Code for theming:
local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), "powerarrow")
beautiful.init(theme_path)
Lines the error says are wrong (553/554):
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
So, what's the problem?

Write a value with opc ua Python

i trying write value with this example :
opc ua client to server
But i have this error :
Exception "unhandled opcua.ua.uaerrors._auto.BadTypeMismatch"
"The value supplied for the attribute is not of the same type as the attribute"s value."(BadTypeMismatch)
File: C:\Users\lari\AppData\Local\Programs\Python\Python38\lib\site-packages\opcua\ua\uatypes.py, Line: 218
someone can help me please
thank you so much
I find \o/
this link help me : https://github.com/FreeOpcUa/opcua-asyncio/issues/30
dv = ua.DataValue(ua.Variant(122, ua.VariantType.Int32))
dv.ServerTimestamp = None
dv.SourceTimestamp = None
trou.set_value(dv)
I hope my adventure can help others ;)
This is telling you the server is expecting a value with a different datatype than the one you wrote.

How to catch errors (Smartsheet API Python SDK)

I am missing fundamental knowledge.
How to 'properly' catch errors returned by the API.
I'm using Python 3.+
If I pass in the wrong sheet ID
try:
update_sht = SmSh.Sheets.get_sheet(dd_id)
print("OK?:", update_sht, flush=True)
except:
print("Error Print:\n", update_sht)
I get this response (in the IPython console)
Response: {
status: 404 Not Found
content: {
{
"errorCode": 1006,
"message": "Not Found",
"refId": "jod4cgoou0sw"
}
}
OK?: {"result": {"code": 1006, "errorCode": 1006, "message": "Not Found",
"name": "ApiError", "recommendation": "Do not retry without fixing the
problem. ", "refId": "jod4cgoou0sw", "shouldRetry": false,
"statusCode": 404}}
and while it returns an error response, it isn't an exception according to try/except.
At this point, I would like to exit out of the loop I am in, instead of continuing on until I get to other lines of code like this
for col in update_sht.columns:
that DO give errors that cause the program to fail.
Traceback (most recent call last):
File "<ipython-input-195-85dde6ec7071>", line 1, in <module>
xxx(debug=False)
File "<ipython-input-194-0b889c817b08>", line 75, in xxx
for col in update_sht.columns:
AttributeError: 'Error' object has no attribute 'columns'
I'm doing more than one thing on the sheet, if I find it, and would prefer not to have a try/except around error line of code (I exaggerate) unless I need them for other errors.
I know/hope this is easier than I have been trying to make it, but as I opened with, I am missing something fundamental.
-Craig
---- UPDATE ----
I am going around in circles.
If errors_as_exceptions is true, then this
update_sht = SmSh.Sheets.get_sheet(dd_id)
raises and exception, but
print(update_sht)
or anything similar shows the previous good value in the object.
How do I determine the status code and error codes so I can take appropriate action?
Nothing I have tried has worked.
If errors_as_exceptions is false, then this
update_sht = SmSh.Sheets.get_sheet(dd_id)
print(update_sht.result.code)
gives me the error code, but only when there is an error ... so I need to catch the error that occurs when there is no
error.
If I raise the error (errors_as_exceptions=True), how do I determine the status code and error code and if I don't raise the error,
how do I do the same?
I want to prevent my code from failing and give the user useful information on what needs to be fixed.
If you set ss.errors_as_exceptions() and your code looks something like this
try:
my_sheet = ss.Sheets.get_sheet(sheet_ID)
print(my_sheet)
except Exception as e:
print(e.message)
The result will look something like this 1006: Not Found. So, the exception message appears to be errorCode:message.
If you want the Python SDK to raise exceptions for API errors call the errors_as_exceptions method on the client object, e.g.
ss = smartsheet.Smartsheet()
ss.errors_as_exceptions()

Resources