Web service - OData option field

foo_barfoo_bar Member Posts: 91
Hello,

we have an external program, that is communicating with navision through OData webservice.
We have a problem while trying to create a comment record, where we have to define the "table data" field which is an option field.
This is the payload that we send:
{
      "Table_Name": "Vendor",
      "Line_No": "2",
      "No": "S00001"
    }

This is the response that we get
{
  "odata.error": {
    "code": "",
    "message": {
      "lang": "en-US",
      "value": "The field No. of table Comment Line contains a value (S00001) that cannot be found in the related table (G/L Account)."
    }
  }
}

Seems to mee that he is not validating the table_name option field.
Do I have to format this in a special way?

thank you,

Lorenzo

Best Answer

  • foo_barfoo_bar Member Posts: 91
    Answer ✓
    I've come to the conclusion, that the problem is not the option field itself.

    But the order or way of processing the fields?

    If I send this as a payload:
    {
      "Table_Name": "Vendor",
      "Comment": "test comment"
    }
    

    I get this as result:
    {
      "Table_Name": "Vendor",
      "No": "S00001",
      "Line_No": 150000,
      "Date": "2016-10-08T00:00:00",
      "Comment": "test comment",
      "Code": "",
      "ETag": "48;YQAAAACLAgAAAAJ7/1MAMAAwADAAMAAxAAAAAIfwSQIAAAA=8;186228330;"
    }
    

    So my problem is that the "Table_Name" field is not being validated before the "No" field is being filled?

Answers

  • ishwarsharma016ishwarsharma016 Member Posts: 50
    Please try passing integer value for the "Table Name" field. For Vendor I think you can pass the value 2 and try.

    P.s- 2 is the index of Vendor in "Table Name" option field.
    Thanks,
    Ishwar Sharma

    My Blogs: Dynamics Community Blog | Blogspot
    Connect: Google + | Twitter
  • foo_barfoo_bar Member Posts: 91
    Hello,

    thx for your suggestion, but i've forgot to mention that i've allready tried that, same result.
  • foo_barfoo_bar Member Posts: 91
    Answer ✓
    I've come to the conclusion, that the problem is not the option field itself.

    But the order or way of processing the fields?

    If I send this as a payload:
    {
      "Table_Name": "Vendor",
      "Comment": "test comment"
    }
    

    I get this as result:
    {
      "Table_Name": "Vendor",
      "No": "S00001",
      "Line_No": 150000,
      "Date": "2016-10-08T00:00:00",
      "Comment": "test comment",
      "Code": "",
      "ETag": "48;YQAAAACLAgAAAAJ7/1MAMAAwADAAMAAxAAAAAIfwSQIAAAA=8;186228330;"
    }
    

    So my problem is that the "Table_Name" field is not being validated before the "No" field is being filled?
Sign In or Register to comment.