Question: I am creating an API's endpoint that creates a post:

```
POST > /posts

```

Each post can have up to one Category and multiple Tags.

When creating a post I need to reference its Category and Tags if any:

1. To reference the Category usually I send the CategoryId;
2. To reference the Tags usually I send Tags names because some of them might be new.

So my Json would be something like:

```
{
  "title": "Some title",
  "content": "Some content",
  "categoryId": 1,
  "tagsNames": ["adventure", "drama"]
}

```

Or should I allow, as an option, to reference the category by name and tags by ids:

```
{
  "title": "Some title",
  "content": "Some content",
  "categoryName": "books",
  "tagsIds": [1, 2]
}

```

To not have different endpoints I could use the following:

```
{
  "title": "Some title",
  "content": "Some content",
  "category": {
    "id": 1,
    "name": null
  },
  "tags": [
    {
      "id": null,
      "name": "adventure"
    },
    {
      "id": null,
      "name": "drama"
    }
  ]
}

```

Then the backend determines how category and tags are referenced: by id or name.

Is there a standard for this?

Answer: 
Let me try this [oulipo](https://en.wikipedia.org/wiki/Oulipo) challenge.

> 
> Write an OPL models that works and that contains what you wrote.
> 
> 
> 

Could this help?

```
float k=1.2;
dvar boolean y[1..1];
int parameter1=1;
int parameter2=2;
dvar boolean x;
dexpr float method[i in 1..10,j in 1..10]=x*(i+j);

subject to
{
forall(i in 1..1)
  k*y[i] >= method[parameter1,parameter2];
}

```

PS: with your later comments:

```
float k=1.2;
dvar boolean y[1..1];
int parameter1=1;
int parameter2=2;
dvar boolean x;
float methodresults[i in 1..10,j in 1..10]; //=x*(i+j);
range r=1..10;
execute
{
function method(i,j)
{
return i+j;
}

for(var i in r) for (var j in r) methodresults[i][j]=method(i,j);
}

subject to
{
forall(i in 1..1)
  k*y[i] >= x*methodresults[parameter1,parameter2];
}

```
If you are using a script in a `.mod` file, then you can define a function whithin an `execute` block [1]. These blocks define pre-processing or post-processing instructions written in ILOG Script [2]. Here's a trivial example from the documentation at <https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/OPL_Studio/opllangref/topics/opl_langref_script_struct_statements_function.html>.

```
execute {
   function add(a, b) {
       return a+b
   }
   writeln(add(1,2));
}

```

[1] <https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/OPL_Studio/opllanguser/topics/opl_languser_script_intro_presynt.html>

[2] <https://www.ibm.com/support/knowledgecenter/SSSA5P_12.9.0/ilog.odms.ide.help/OPL_Studio/opllanguser/topics/opl_languser_script.html>