# Problem with .api Configuration

**URL:** https://forum.legato.io/t/problem-with-api-configuration/5537
**Category:** Uncategorized
**Created:** [December 7, 2020, 8:55am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537 "2020-12-07T08:55:34Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 8:55am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/1 "2020-12-07T08:55:34Z")

</div>

Hey, i wrote a function getConfig that reads a file “config.conf” in one App.  
Now i want to call that Function in another App using a .api file. I guess somethings wrong with my API file but i am not sure what. But after specifying the api file and compiling i get following error:

/home/reinhard/myLeafWorkspace/CL\_Agents/Components/CL\_ConfigComponent/CL\_Config.c:26:6: error: conflicting types for ‘IF\_Config\_getConfig’  
void IF\_Config\_getConfig(char\* customerId,char\* siteId, char\* locationId, char\* host, int\* port, int\* enableTls);

(Without the API file it compiles fine)

My API file looks like this:

FUNCTION int32 getConfig  
(  
string customerId[7] OUT,  
string siteId[5] OUT,  
string locationId[2] OUT,  
string host[30] OUT,  
int32 port OUT,  
int32 enableTls OUT  
);

Thanks in advance!

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [December 7, 2020, 9:15am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/2 "2020-12-07T09:15:54Z")

</div>

you can delete one by one to know which one makes the problem:

string customerId[7] OUT,  
string siteId[5] OUT,  
string locationId[2] OUT,  
string host[30] OUT,  
int32 port OUT,  
int32 enableTls OUT

---

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 9:28am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/3 "2020-12-07T09:28:59Z")

</div>

It seems to be all of them, when i change OUT to IN and change char\* to const char\* i stop getting that error but of course i don’t want to send the DAta in i want to get the data out.

The function is declared like:  
int IF\_Config\_getConfig(char\* customerId,char\* siteId, char\* locationId, char\* host, int\* port, int\* enableTls);

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [December 7, 2020, 9:38am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/4 "2020-12-07T09:38:24Z")

</div>

From your previous discussion thread, the IPC\_step4.rar already use both OUT and IN, but you say it is ok.

> [@Biderectional communication between Apps](https://forum.legato.io/t/biderectional-communication-between-apps/5532/7):
>
> It works now! Thanks for your Help!

And here says string must be IN:

> **[Syntax - Legato Docs](https://docs.legato.io/latest/apiFilesSyntax.html#apiFilesSyntax_typesStruct)**
>
> legato™ is an open source Linux-based embedded platform designed to simplify connected IoT application development

---

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 9:45am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/5 "2020-12-07T09:45:36Z")

</div>

Oh, that’s because I changed it up for my needs and i only needed IN.

Where does it say that? Under “Specifying a Function” a OUT string is listed as an example.

---

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 10:14am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/6 "2020-12-07T10:14:55Z")

</div>

I now tried passing the Data as struct and i get following error:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/legato1/original/2X/8/84877caaa81ea2c3aa817b63bbccc05e523bd717.png)

API:

STRUCT SWI\_Config  
{  
string customerId[7];  
string siteId[5];  
string locationId[2];  
string host[30];  
int32 port;  
int32 enableTls;  
};

FUNCTION SWI\_Config getConfig  
(  
);

Function:  
IF\_Config\_SWI\_Config\_t IF\_Config\_getConfig();

---

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 10:25am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/7 "2020-12-07T10:25:52Z")

</div>

Got it to work using struct.  
Still thanks!

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)
#### Post date: [December 7, 2020, 10:58am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/8 "2020-12-07T10:58:35Z")

</div>

I found that you need to add one more parameter(message2Size) in the .c file in case you need to add OUT string:

```
void logger_logMessage
(
	const char* message , ///< [IN]
char* message2,
       
    size_t message2Size
)
{
	LE_INFO( PREFIX_LOG_MSG "received the message \"%s\" from a client.",
		     message );

	snprintf( message2, MESSAGE_SIZE,
		          "1234123412341324");
		message2[MESSAGE_MAX] = '\0';

}

FUNCTION logMessage
(
	string	message[MSG_API_SIZE] IN,
	string	message2[MSG_API_SIZE] OUT
);

```

---

<div class="post-metadata">

### Author: ![reinhard2](https://avatars.discourse-cdn.com/v4/letter/r/958977/32.png) [@reinhard2](https://forum.legato.io/u/reinhard2)
#### Post date: [December 7, 2020, 11:02am UTC](https://forum.legato.io/t/problem-with-api-configuration/5537/9 "2020-12-07T11:02:24Z")

</div>

Thanks that will be very useful!
