# REST API arguments - is there a better way?

**URL:** <https://community.particle.io/t/rest-api-arguments-is-there-a-better-way/960>\
**Category:** Cloud\
**Created:** [December 23, 2013, 10:59pm UTC](https://community.particle.io/t/rest-api-arguments-is-there-a-better-way/960 "2013-12-23T22:59:55Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [October 13, 2016, 5:04am UTC](https://community.particle.io/t/rest-api-arguments-is-there-a-better-way/960/20 "2016-10-13T05:04:31Z")

</div>

> [@Ludocomito](#):
>
> so could you be so kind to post the correct code?

We see ourselves more as enablers and educators not as coder-bots.  
I've pointed you in your other thread to some functions.

> [@Read data from xml file](https://community.particle.io/t/read-data-from-xml-file/26476/2):
>
> That’s normal string parsing. Scan for TOT=" and take the portion up to ". I’d use [strstr()](http://www.cplusplus.com/reference/cstring/strstr/) for finding the first part and then again strstr() or [strpbrk()](http://www.cplusplus.com/reference/cstring/strpbrk/). Or, if you want the numeric value, locate the beginning (as above) and then take the string after TOT=" into [atof()](http://www.cplusplus.com/reference/cstdlib/atof/) or [strtod()](http://www.cplusplus.com/reference/cstdlib/strtod/) Or you use the way shown in the docs wink[https://docs.particle.io/tutorials/topics/webhooks/#the-firmware-1](https://docs.particle.io/tutorials/topics/webhooks/#the-firmware-1)

You just need to investigate and look at the samples in the provided links.

* * *

One additional hint for above code could be the use of `strlen()`

```cpp
void myHandler(const char *event, const char *data) // pointers to so-called c-string arrays 'event' and 'data' are passed to the handler function
{
  char myData[strlen(data)+1] = ""; //create a string array big enough to capture what's pointed to by 'data'
  strncpy(myData, data, sizeof(myData)); // copy whats pointed to by 'data' to 'myData', this function will not overflow the size of myData
  ...
  // parse to get what you need from myData;
  ...
}

```

---

_[View the full topic](https://community.particle.io/t/rest-api-arguments-is-there-a-better-way/960)._
