@Robert Cemper 

Hope this is something better.

Class REST.BOOK Extends %Library.Persistent 

{

Property Title As REST.TITLE;

Property Author As %String;

Storage Default

{

<Data name="BOOKDefaultData">

<Value name="1">

<Value>%%CLASSNAME</Value>

</Value>

<Value name="2">

<Value>Title</Value>

</Value>

<Value name="3">

<Value>Author</Value>

</Value>

</Data>

<DataLocation>^REST.BOOKD</DataLocation>

<DefaultData>BOOKDefaultData</DefaultData>

<IdLocation>^REST.BOOKD</IdLocation>

<IndexLocation>^REST.BOOKI</IndexLocation>

<StreamLocation>^REST.BOOKS</StreamLocation>

<Type>%Library.CacheStorage</Type>

}

}

Class RESTAPI.TITLE Extends %Library.Persistent

{

Index IDKeyIndex On RowId [ IdKey, PrimaryKey, Unique ];

Property RowId As %Library.String(COLLATION = "EXACT", TRUNCATE = 0) [ Required, SqlColumnNumber = 1, SqlFieldName = RowId ];

Property Title As %String;

Property Text As %String;

Storage Default

{

<Data name="TITLEDefaultData">

<Value name="1">

<Value>%%CLASSNAME</Value>

</Value>

<Value name="2">

<Value>Title</Value>

</Value>

<Value name="3">

<Value>Text</Value>

</Value>

</Data>

<DataLocation>^REST.TITLED</DataLocation>

<DefaultData>TITLEDefaultData</DefaultData>

<IdLocation>^REST.TITLED</IdLocation>

<IndexLocation>^REST.TITLEI</IndexLocation>

<StreamLocation>^REST.TITLES</StreamLocation>

<Type>%Library.CacheStorage</Type>

}

}

@Robert Cemper 

set book=##class(BOOK).%New()

set book.RowId=obj.ID     ;  from JSON obj

set book.Title=obj.Title    ;  from JSON obj ------->This line causes an OREF error I tried this initially, the Json object is a string eg "CACHE BOOK" and I want to save the RowId in the Title row in BOOK table when creating a new object in book.

do book.%Save()

Retrieving an existing ID I managed to work on that the problem or issue came to creating a new object in BOOK where I have to get RowId inserted into Title field given the obj.Title from postman is a string.

@Robert Cemper 

I have a table called TITLE which is generated form a class TITLE in RESTAPI folder so the package is RESTAPI.TITLE and I am creating a new object in another Book class but it has TITLE as a foreign key.

So if I want to insert data in the BOOK class the field for Title in the BOOK class is a foreign key in which is a primary key RowID in the TITLE class.

Given the new object I am creating is this {"ID":17, "Title":"LEARNING CAHE REST API"}

the title field in the BOOK class should give me the RowID which is 2

so in the BOOK class the ID = 17 and Title = 2

That is what I'm trying to work out. 

@Robert Cemper 
Thank you taht solves the problem for the OREF the challenge I find around it it doesn't post the data to the database the object I have can look like this

{"ID":17, "Title":"LEARNING CAHE REST API"}

I want it to store the following in the database

ID - > autoincrement - this I know how to do it.
Title -> I want to store the ID where Value is "LEARNING CAHE REST API" in the All.Allbooks table

Thank you for all you help. it has open my eyes more. sorry if I ask the obvious questions I'm A C#/ASP.NET developer trying to learn Objectscript/CACHE/MUMPS