# Import TrackedEntityInstances through api

**URL:** <https://community.dhis2.org/t/import-trackedentityinstances-through-api/30850>\
**Category:** Support - Assistance technique\
**Created:** [15 October 2015 09:29 UTC](https://community.dhis2.org/t/import-trackedentityinstances-through-api/30850 "2015-10-15T09:29:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Tumwesigye](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@Alex\_Tumwesigye](https://community.dhis2.org/u/Alex_Tumwesigye)\
**Post date:** [15 October 2015 09:29 UTC](https://community.dhis2.org/t/import-trackedentityinstances-through-api/30850/1 "2015-10-15T09:29:45Z")

</div>

Dear Tracker Team,

I am trying to import trackedEntityInstances (json file) for HISP Uganda demo.

When I send the json file, I get an error below.

- Connection #0 to host [tracker.hispuganda.org](http://tracker.hispuganda.org) left intact

{“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“program is required for program scope”}Done

Below is the json I am sending

{“lastUpdated”:“2014-09-02 13:40:25.845”,“trackedEntity”:“lq6b0EbvbWJ”,“created”:“2014-09-02 13:40:25.416”,“orgUnit”:“V5XvX1wr1kF”,“trackedEntityInstance”:“qqPocsUTn0D”,“relationships”:[],“attributes”:[{“displayName”:“Gravida”,“valueType”:“NUMBER”,“attribute”:“UuNwH6pSBfT”,“value”:“1”},{“displayName”:“ANC Client Number”,“valueType”:“TEXT”,“attribute”:“XS1hnJSUhJR”,“value”:“18887X8YP2015”},{“displayName”:“Para (\>7 months)”,“valueType”:“NUMBER”,“attribute”:“rKqAjEn6zrS”,“value”:“0”},{“displayName”:“Para (miscarriages \< 7 months)”,“valueType”:“NUMBER”,“attribute”:“pRgEk4Ao5CO”,“value”:“0”},{“displayName”:“Age”,“valueType”:“NUMBER”,“attribute”:“j7gaoJddiXp”,“value”:“22”}]}

What is the right endpoint for trackedEntityInstances while respecting the programScope.

I am using 2.21 snapshot build 20702

I believe it is the same with 2.20. We need this to meet the deadline.

Alex

Thanks.

> **···**
>
> Alex Tumwesigye
> 
> Technical Advisor - DHIS2 (Consultant),  
> Ministry of Health/AFENET
> 
> Kampala
> 
> Uganda
> 
> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
> 
> IT Specialist (Servers, Networks and Security, Health Information Systems - DHIS2 ) & Solar Consultant
> 
> +256 774149 775, + 256 759 800161
> 
> "I don’t want to be anything other than what I have been - one tree hill "

---

<div class="post-metadata">

**Author:** ![morten](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/morten/32/36295_2.png) [@morten](https://community.dhis2.org/u/morten)\
**Post date:** [15 October 2015 09:33 UTC](https://community.dhis2.org/t/import-trackedentityinstances-through-api/30850/2 "2015-10-15T09:33:26Z")

</div>

Hi

One of the attributes you are sending in is using scope = program, which means it needs to know which program this belongs to… since you are just creating a TEI without doing enrollment etc… maybe its a misconfiguration? probably the scope is wrong?

> **···**
>
> On Thu, Oct 15, 2015 at 4:29 PM, Alex Tumwesigye [atumwesigye@gmail.com](mailto:atumwesigye@gmail.com) wrote:
> 
> > Dear Tracker Team,
> 
> > I am trying to import trackedEntityInstances (json file) for HISP Uganda demo.
> 
> > 
> 
> > When I send the json file, I get an error below.
> 
> > 
> 
> > - Connection #0 to host [tracker.hispuganda.org](http://tracker.hispuganda.org) left intact
> 
> > {“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“program is required for program scope”}Done
> 
> > 
> 
> > 
> 
> > Below is the json I am sending
> 
> > 
> 
> > 
> 
> > {“lastUpdated”:“2014-09-02 13:40:25.845”,“trackedEntity”:“lq6b0EbvbWJ”,“created”:“2014-09-02 13:40:25.416”,“orgUnit”:“V5XvX1wr1kF”,“trackedEntityInstance”:“qqPocsUTn0D”,“relationships”:,“attributes”:[{“displayName”:“Gravida”,“valueType”:“NUMBER”,“attribute”:“UuNwH6pSBfT”,“value”:“1”},{“displayName”:“ANC Client Number”,“valueType”:“TEXT”,“attribute”:“XS1hnJSUhJR”,“value”:“18887X8YP2015”},{“displayName”:“Para (\>7 months)”,“valueType”:“NUMBER”,“attribute”:“rKqAjEn6zrS”,“value”:“0”},{“displayName”:“Para (miscarriages \< 7 months)”,“valueType”:“NUMBER”,“attribute”:“pRgEk4Ao5CO”,“value”:“0”},{“displayName”:“Age”,“valueType”:“NUMBER”,“attribute”:“j7gaoJddiXp”,“value”:“22”}]}
> 
> > 
> 
> > What is the right endpoint for trackedEntityInstances while respecting the programScope.
> 
> > 
> 
> > I am using 2.21 snapshot build 20702
> 
> > I believe it is the same with 2.20. We need this to meet the deadline.
> 
> > 
> 
> > Alex
> 
> > 
> 
> > Thanks.
> 
> > 
> 
> > –  
> > Alex Tumwesigye
> 
> > 
> 
> > Technical Advisor - DHIS2 (Consultant),  
> > Ministry of Health/AFENET
> 
> > Kampala
> 
> > Uganda
> > 
> > IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
> > 
> > IT Specialist (Servers, Networks and Security, Health Information Systems - DHIS2 ) & Solar Consultant
> > 
> > +256 774149 775, + 256 759 800161
> 
> > "I don’t want to be anything other than what I have been - one tree hill "
> 
> > * * *
> > 
> > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > 
> > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> –  
> Morten

---

<div class="post-metadata">

**Author:** ![Alex\_Tumwesigye](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@Alex\_Tumwesigye](https://community.dhis2.org/u/Alex_Tumwesigye)\
**Post date:** [15 October 2015 10:00 UTC](https://community.dhis2.org/t/import-trackedentityinstances-through-api/30850/3 "2015-10-15T10:00:25Z")

</div>

Dear Morten,

Yes. You are right. One of the attribute was unique “program within organisationunit”.

I just disabled it and it worked. I will re-enable after import.

Alex

> **···**
>
> On Thu, Oct 15, 2015 at 12:33 PM, Morten Olav Hansen [mortenoh@gmail.com](mailto:mortenoh@gmail.com) wrote:
> 
> > Hi
> 
> > One of the attributes you are sending in is using scope = program, which means it needs to know which program this belongs to… since you are just creating a TEI without doing enrollment etc… maybe its a misconfiguration? probably the scope is wrong?
> 
> –
> 
> –  
> Morten
> 
> On Thu, Oct 15, 2015 at 4:29 PM, Alex Tumwesigye [atumwesigye@gmail.com](mailto:atumwesigye@gmail.com) wrote:
> 
> > Dear Tracker Team,
> 
> > I am trying to import trackedEntityInstances (json file) for HISP Uganda demo.
> 
> > 
> 
> > When I send the json file, I get an error below.
> 
> > 
> 
> > - Connection #0 to host [tracker.hispuganda.org](http://tracker.hispuganda.org) left intact
> 
> > {“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“program is required for program scope”}Done
> 
> > 
> 
> > 
> 
> > Below is the json I am sending
> 
> > 
> 
> > 
> 
> > {“lastUpdated”:“2014-09-02 13:40:25.845”,“trackedEntity”:“lq6b0EbvbWJ”,“created”:“2014-09-02 13:40:25.416”,“orgUnit”:“V5XvX1wr1kF”,“trackedEntityInstance”:“qqPocsUTn0D”,“relationships”:,“attributes”:[{“displayName”:“Gravida”,“valueType”:“NUMBER”,“attribute”:“UuNwH6pSBfT”,“value”:“1”},{“displayName”:“ANC Client Number”,“valueType”:“TEXT”,“attribute”:“XS1hnJSUhJR”,“value”:“18887X8YP2015”},{“displayName”:“Para (\>7 months)”,“valueType”:“NUMBER”,“attribute”:“rKqAjEn6zrS”,“value”:“0”},{“displayName”:“Para (miscarriages \< 7 months)”,“valueType”:“NUMBER”,“attribute”:“pRgEk4Ao5CO”,“value”:“0”},{“displayName”:“Age”,“valueType”:“NUMBER”,“attribute”:“j7gaoJddiXp”,“value”:“22”}]}
> 
> > 
> 
> > What is the right endpoint for trackedEntityInstances while respecting the programScope.
> 
> > 
> 
> > I am using 2.21 snapshot build 20702
> 
> > I believe it is the same with 2.20. We need this to meet the deadline.
> 
> > 
> 
> > Alex
> 
> > 
> 
> > Thanks.
> 
> > 
> 
> > –  
> > Alex Tumwesigye
> 
> > 
> 
> > Technical Advisor - DHIS2 (Consultant),  
> > Ministry of Health/AFENET
> 
> > Kampala
> 
> > Uganda
> > 
> > IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
> > 
> > IT Specialist (Servers, Networks and Security, Health Information Systems - DHIS2 ) & Solar Consultant
> > 
> > +256 774149 775, + 256 759 800161
> 
> > "I don’t want to be anything other than what I have been - one tree hill "
> 
> > 
> 
> > * * *
> > 
> > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > 
> > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> Alex Tumwesigye
> 
> Technical Advisor - DHIS2 (Consultant),  
> Ministry of Health/AFENET
> 
> Kampala
> 
> Uganda
> 
> IT Consultant - BarefootPower Uganda Ltd, SmartSolar, Kenya
> 
> IT Specialist (Servers, Networks and Security, Health Information Systems - DHIS2 ) & Solar Consultant
> 
> +256 774149 775, + 256 759 800161
> 
> "I don’t want to be anything other than what I have been - one tree hill "
