Function metadata was not found for action Target NormTimeseriesDouble bindings

#1

I’m doing curl for Facility.evalMetrics, with the same spec it works fine on console, but with curl I get

ERROR: Internal error: function metadata was not found for action Target [engie-osep/sbox/NormTimeseriesDouble?action=bindings]

Here is the eval metric from console

Facility.evalMetrics({"ids": ["0001"],"expressions": ["SmartMeterMeasurementSumOverObjsSumOverTime"],"start": "2018-01-01T00:00:00.000","end": "2018-12-31T23:59:59.999","interval": "MONTH","include": "bindings","bindings": {"type": "[map<string, any>]","value": [{"r": "Electricity","mt": "consumption"},{"r": "naturalgas","mt": "consumption"},{"r": "h_water","mt": "consumption"},{"r": "Cooling_Water","mt": "consumption"},{"r": "steam","mt": "consumption"}]},"continueOnError": false,"cache": false,"timeZone": "NONE"})

Here is the evalMetrics with curl:

curl -u user:pass -v -H "Content-Type: application/json" -H "Accept: application/json"  -X POST -d '{"spec": {"ids": ["0001"],"expressions": ["SmartMeterMeasurementSumOverObjsSumOverTime"],"start": "2018-01-01T00:00:00.000","end": "2018-12-31T23:59:59.999","interval": "MONTH","include": "bindings","bindings": {"type": "[map<string, any>]","value": [{"r": "Electricity","mt": "consumption"},{"r": "naturalgas","mt": "consumption"},{"r": "h_water","mt": "consumption"},{"r": "Cooling_Water","mt": "consumption"},{"r": "steam","mt": "consumption"}]},"continueOnError": false,"cache": false,"timeZone": "NONE"}}'  https://tenant-sandbox.c3iot.com/api/1/tenant/sbox/Facility?action=evalMetrics

Here is full error

Note: Unnecessary use of -X or --request, POST is already inferred.

* Trying 52.31.230.247...

* TCP_NODELAY set

* Connected to engie-osep-sandbox.c3iot.com (52.31.230.247) port 443 (#0)

* ALPN, offering h2

* ALPN, offering http/1.1

* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH

* successfully set certificate verify locations:

* CAfile: /etc/ssl/cert.pem

CApath: none

* TLSv1.2 (OUT), TLS handshake, Client hello (1):

* TLSv1.2 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS change cipher, Client hello (1):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS change cipher, Client hello (1):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256

* ALPN, server did not agree to a protocol

* Server certificate:

* subject: OU=Domain Control Validated; CN=*.c3iot.com

* start date: Jan 30 23:17:00 2018 GMT

* expire date: Feb 22 23:27:38 2019 GMT

* subjectAltName: host "engie-osep-sandbox.c3iot.com" matched cert's "*.c3iot.com"

* issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2

* SSL certificate verify ok.

* Server auth using Basic with user 'bachir.chihani@c3iot.com'

&gt; POST /api/1/engie-osep/sbox/Facility?action=evalMetrics HTTP/1.1

&gt; Host: engie-osep-sandbox.c3iot.com

&gt; Authorization: Basic

&gt; User-Agent: curl/7.54.0

&gt; Content-Type: application/json

&gt; Accept: application/json

&gt; Content-Length: 509

&gt; 

* upload completely sent off: 509 out of 509 bytes

&lt; HTTP/1.1 500 Server Error

&lt; Access-Control-Allow-Origin: *

&lt; Content-Language: en-US

&lt; Content-Type: application/json;charset=utf-8

&lt; Date: Mon, 08 Oct 2018 14:11:13 GMT

&lt; Expires: Thu, 01 Jan 1970 00:00:00 GMT

&lt; Server: Jetty(9.4.9.v20180320)

&lt; Set-Cookie: c3tenant=engie-osep;Path=/;Domain=engie-osep-sandbox.c3iot.com;Secure

&lt; Set-Cookie: c3tag=sbox;Path=/;Domain=engie-osep-sandbox.c3iot.com;Secure

&lt; Set-Cookie: c3canonical=false;Path=/;Domain=engie-osep-sandbox.c3iot.com;Secure

&lt; Vary: Accept-Encoding, User-Agent

&lt; X-Action-Info: 1540.6393540

&lt; X-C3-Canonical: false

&lt; X-C3-Tag: sbox

&lt; X-C3-Tenant: engie-osep

&lt; X-Frame-Options: SAMEORIGIN

&lt; X-Timing-Info: total=0.046279,cpu=0.042799,io=0.003415

&lt; Content-Length: 140

&lt; Connection: keep-alive

&lt; 

 *** ERROR: Internal error: 

* Connection #0 to host engie-osep-sandbox.c3iot.com left intact

function metadata was not found for action Target [engie-osep/sbox/NormTimeseriesDouble?action=bindings]

any hint?

#2

can you share your curl command?

#3

I was about to update the post with the curl command :slight_smile:

#4

Trying the same command with this additional header -H "X-C3-Type-Aware: true" seems to do the job.
The rest-binding topic talk a bit about this header:

true or 1 indicates that caller is aware of c3 type system and private fields should be sent over the wire (see below)

X-C3-Type-Aware Request Header

Some of the C3 type implementations involve storing values in private fields and then implementing C3 type-system functions for accessing this data. Serialization of these types over wire differs based on weather or not caller is fully aware of C3 type-system or consuming data from C3 server as is. X-C3-Type-Aware header is used to differentiate between these two cases.

For example C3 Timeseries type has functions like data() to access internal data structures stored in m_data private field

E.g. assuming timeseries represents electricity consumption over 3 month period the following two json represent same timeseries in two different way