0

I used HANA XS on SAP Cloud Platform Neo to create a HANA DB and expose it via OData - unable to POST using Postman. I get a 400 - Bad Request - "Syntax error at position 0."

Here is the .xsodata file contents:

service{
    "com.******.jereclass::JeReclassHistory";
}

Here is the .xsaccess file contents:

{
    "exposed": true,
    "authentication": [{
        "method": "Form"
    }],

    "mime_mapping": [{
        "extension": "jpg",
        "mimetype": "image/jpeg"
    }],
    "force_ssl": false,
    "enable_etags": true,
    "prevent_xsrf": false,
    "anonymous_connection": null,
    "cors": [{
        "enabled": true,
        "allowMethods":["GET","POST"]
    }],
    "cache_control": "no-cache, no-store",
    "default_file": "index.html"
}

Here is the .hdbschema file contents:

schema_name = "JE_Reclass";

Here is the .hdbtable file contents:

table.schemaName = "JE_Reclass";
table.tableType  = COLUMNSTORE;
table.columns    = [
                    { name = "Department";  sqlType = VARCHAR; nullable = false; length = 20; },
                    { name = "MapName";     sqlType = VARCHAR; nullable = false; length = 30; },
                    { name = "FiscalYear";  sqlType = VARCHAR; nullable = false; length = 4;  },
                    { name = "Period";      sqlType = VARCHAR; nullable = false; length = 3;  },
                    { name = "RunID";       sqlType = VARCHAR; nullable = false; length = 30; },
                    { name = "PostingDate"; sqlType = DATE;    nullable = false; },
                    { name = "FromDate";    sqlType = DATE;    nullable = false; },
                    { name = "FromTime";    sqlType = TIME;    nullable = false; },
                    { name = "ToDate";      sqlType = DATE;    nullable = false; },
                    { name = "ToTime";      sqlType = TIME;    nullable = false; },    
                    { name = "CreateBy";    sqlType = VARCHAR; nullable = false; length = 12; },
                    { name = "CreateDate";  sqlType = DATE;    nullable = false; },
                    { name = "CreateTime";  sqlType = TIME;    nullable = false; }
                   ];
table.primaryKey.pkcolumns = ["Department", "MapName", "FiscalYear", "Period", "RunID"];

****Postman:****

POST /com/*******/jereclass/JeReclassHistorySvc.xsodata/JeReclassHistory HTTP/1.1
Host: jereclass******.us3.hana.ondemand.com
Content-Type: application/json
Authorization: Basic **************
User-Agent: PostmanRuntime/7.18.0
Accept: */*
Cache-Control: no-cache
Postman-Token: ***********************
Host: jereclass******.us3.hana.ondemand.com
Accept-Encoding: gzip, deflate
Content-Length: 456
Cookie: *****************************
Connection: keep-alive
cache-control: no-cache

{
    "Department": "Payroll",
    "MapName": "TEST JE RECLASS",
    "FiscalYear": "2013",
    "Period": "01",
    "RunID": "20130112134231-SCURRY",
    "PostingDate": "2013-01-12T00:00:00.0000000",
    "FromDate": "2013-01-01T00:00:00.0000000",
    "FromTime": "PT1H10M54S",
    "ToDate": "2013-01-12T00:00:00.0000000",
    "ToTime": "PT13H42M30S",
    "CreateBy": "SCURRY",
    "CreateDate": "2013-01-12T00:00:00.0000000",
    "CreateTime": "PT14H5M7S"
}
scurry
  • 19
  • 5
  • Is a GET working? – Abdel Dadouche Oct 16 '19 at 21:01
  • Yes, GET is working. – scurry Oct 17 '19 at 13:38
  • So it might be an CSRF token issue.Have you check that? – Abdel Dadouche Oct 17 '19 at 14:09
  • I believe so: When I had "prevent_xsrf" set to false, it shouldn't have cared about CSRF - and I get the syntax error. Even when I set "prevent_xsrf" to true, it would give me a 403 'Forbidden' error. When I provided an xsrf token in the header of the POST, it again gave me the syntax error. I wonder if there's some problem with the date or time fields .... – scurry Oct 17 '19 at 18:12
  • I am having challenges with the HANA date data-type - this is what is causing the problem. I do not yet know how to correctly format the date in the JSON object within the body of the Postman POST request. – scurry Oct 17 '19 at 19:06

1 Answers1

0

Using (for example) "PostingDate": "/Date(1405699200)/", where "1405699200" is the epoch date worked.

scurry
  • 19
  • 5