# Data Storage Integration

**URL:** <https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741>\
**Category:** The Things Stack v3\
**Created:** [April 15, 2021, 7:04am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741 "2021-04-15T07:04:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 15, 2021, 7:04am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/1 "2021-04-15T07:04:57Z")

</div>

Hello everyone,  
I have successfully upgraded my device from V2 to V3 Stack and. I always used in V2 the Swagger to get my sensor data over HTTP.

But in V3 I am confused. Can anyone tell me how I can set up my own database to store my data locally and then retrieve that data over HTTP.

Do you have any documentation or examples?

Thank you

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 15, 2021, 11:30am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/2 "2021-04-15T11:30:37Z")

</div>

If not, is there a way to save only the decoded payload and ID’s in the storage API (like in V2)?

i make the HTTP Request.

curl G -H “Authorization: Bearer NNSXS.HQ3KPZW…LRFDFAI6Q7UIC2G6LT…VLMYYHZXQ”   
-H “Accept: text/event-stream”   
-d “limit=10”   
-d “after=2021-01-20T00:00:00Z”   
-d “field\_mask=up.uplink\_message.decoded\_payload”  
“[https://eu1.cloud.thethings.network/api/v3/as/applications/APP-ID/devices/Device-Name/packages/storage/uplink\_message](https://eu1.cloud.thethings.network/api/v3/as/applications/APP-ID/devices/Device-Name/packages/storage/uplink_message)” \

but i got always the same error.

HTTP/1.1 501 Not Implemented  
content-type: text/event-stream  
referrer-policy: strict-origin-when-cross-origin  
x-content-type-options: nosniff  
x-frame-options: SAMEORIGIN  
x-request-id: cafb7392-899c-47a9-bdf9-86b86e2a3652  
x-xss-protection: 1; mode=block  
date: Thu, 15 Apr 2021 11:12:22 GMT  
content-length: 39  
x-envoy-upstream-service-time: 0  
server: envoy

{“code”:12,“message”:“Not Implemented”}

what i´m doing wrong?

Thank you.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 15, 2021, 2:38pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/3 "2021-04-15T14:38:52Z")

</div>

Try it without the field\_mask - I’m personally am still figuring the exact paths expected but I don’t have any issues with limit or date after.

At present it’s all cURL on the command line, no Swagger to play with.

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 15, 2021, 2:59pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/4 "2021-04-15T14:59:52Z")

</div>

Hello i remove the field\_mask limit and after.

i got another Error.

{“error”:{“grpc\_code”:7,“http\_code”:403,“message”:“error:pkg/auth/rights:insufficient\_application\_rights (insufficient rights for application `app-id@ttn`)”,“http\_status”:“Forbidden”,“details”:[{"@type":"[type.googleapis.com/ttn.lorawan.v3.ErrorDetails",“namespace”:“pkg/auth/rights”,“name”:“insufficient\_application\_rights”,“message\_format”:"insufficient](http://type.googleapis.com/ttn.lorawan.v3.ErrorDetails%22,%22namespace%22:%22pkg/auth/rights%22,%22name%22:%22insufficient_application_rights%22,%22message_format%22:%22insufficient) rights for application `{uid}`",“attributes”:{“uid”:“app-id@ttn”},“correlation\_id”:“374d4c08d53d4491be4e9d8472e49928”,“code”:7}]}}

Normally i want to sve the Sensor Data and retrieve wit HTTPS Request.

can you please tell me step by step how i customize my own Database to save the sensor Data and be able to retrieve this Data over HTTPS Requets?

Thanks

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 15, 2021, 3:14pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/5 "2021-04-15T15:14:42Z")

</div>

> [@Mbakop](#):
>
> can you please tell me step by step how i customize my own Database to save the sensor Data

Sure, for your own personal database I can help. Please DM me your invoicing details …

> [@Mbakop](#):
>
> be able to retrieve this Data over HTTPS Requets?

You need to use an API key that has the permission to download data. Set Read application traffic (uplink and downlink) on. Then you should get your data.

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 16, 2021, 5:53am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/6 "2021-04-16T05:53:15Z")

</div>

i already used my generated API-Key to send the https-request like you see but i always got the error.

I remove the field\_mask limit and after. how can i solve it?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 16, 2021, 3:28pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/7 "2021-04-16T15:28:34Z")

</div>

> [@descartes](#):
>
> You need to use an API key that has the permission to download data. Set Read application traffic (uplink and downlink) on.

Have you done or checked this?

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 16, 2021, 4:04pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/8 "2021-04-16T16:04:33Z")

</div>

yes i checkt it and is done. I retrieve the data with the API Request and i set Read application traffic (uplink and downlink).

but the request don´t work when i use the -d “field\_mask=up.uplink\_message.decoded\_payload”

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 16, 2021, 4:08pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/9 "2021-04-16T16:08:44Z")

</div>

> [@Mbakop](#):
>
> but the request don´t work when i use the -d “field\_mask=up.uplink\_message.decoded\_payload”

One step at a time, mostly because I can’t see your computer screen, so **does it work without the field\_mask?**

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 16, 2021, 4:48pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/10 "2021-04-16T16:48:50Z")

</div>

> [@descartes](#):
>
> One step at a time, mostly because I can’t see your computer screen, so **does it work without the field\_mask?**

yes it work without the filed\_mask

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 16, 2021, 5:13pm UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/11 "2021-04-16T17:13:25Z")

</div>

Well as you are using the mask in the documentation, I’d say there is a bug report you need to file and hopefully it will be fixed.

But in the meanwhile at least you have something working.

Now you have to choose what your server side language of choice is and write the code to take a JSON submission and insert in to a database.

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 19, 2021, 6:30am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/12 "2021-04-19T06:30:39Z")

</div>

> [@descartes](#):
>
> Now you have to choose what your server side language of choice is and write the code to take a JSON submission and insert in to a database.

yes thank you. I have already the code to parse the JSON Data . For the insertion in to a Database that´s my point.

that´s a link that i see on the TTN website.

please look the part “Storage Integration Options” what is the Step to make this configuration.

[https://www.thethingsindustries.com/docs/reference/configuration/application-server/#storage-integration-options](https://www.thethingsindustries.com/docs/reference/configuration/application-server/#storage-integration-options)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 19, 2021, 7:32am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/13 "2021-04-19T07:32:45Z")

</div>

That is in the configuration section for the v3 stack.

TTI, not unsurprisingly, don’t provide instructions on how to write code for databases as it’s a very generic & well documented thing. Given the monumental number of other websites that provide such info, I think Google will be your friend here.

---

<div class="post-metadata">

**Author:** ![Mbakop](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mbakop/32/35697_2.png) [@Mbakop](https://www.thethingsnetwork.org/forum/u/Mbakop)\
**Post date:** [April 19, 2021, 9:10am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/14 "2021-04-19T09:10:44Z")

</div>

> [@descartes](#):
>
> Given the monumental number of other websites that provide such info, I think Google will be your friend here.

Yes, you are right, my problem is not the way I build or program my database, but I thought it was possible to connect the data received by TTS directly to my database without going through the HTTP\_Request.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [April 19, 2021, 10:25am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/15 "2021-04-19T10:25:27Z")

</div>

> [@Mbakop](#):
>
> connect the data received by TTS directly to my database without going through the HTTP\_Request.

Huh??? What did you have in mind for the data to get from the TTN servers to your database? There is no automagic integration that puts your data in to a database.

When the data arrives at the Application Server, it will just disappear in to thin air unless YOU choose to do something with it. Those somethings include:

- MQTT
- WebHooks
- Data Storage

All of which have a well documented API for your data to leave the confines of the TTN servers and get to your servers. All three provide the data as JSON with varying levels of detail. When it arrives, you parse the JSON to prepare it for however your database would like you to insert records, depending on both the database and the language you are using, perform the insert and then, erm, that’s it.

---

<div class="post-metadata">

**Author:** ![system](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/6/2/6250ea44fd2b0d6259489e1a92748df681e1f970.png) [@system](https://www.thethingsnetwork.org/forum/u/system)\
**Post date:** [May 19, 2021, 10:26am UTC](https://www.thethingsnetwork.org/forum/t/data-storage-integration/46741/16 "2021-05-19T10:26:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
