# Query to retrieve studyID from variants not working

**URL:** <https://community.opentargets.org/t/query-to-retrieve-studyid-from-variants-not-working/1037>\
**Category:** GraphQL API\
**Tags:** genetics-portal\
**Created:** [4 April 2023 16:39 UTC](https://community.opentargets.org/t/query-to-retrieve-studyid-from-variants-not-working/1037 "2023-04-04T16:39:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitris\_Zisis](https://dub1.discourse-cdn.com/flex017/user_avatar/community.opentargets.org/dimitris_zisis/32/399_2.png) [@Dimitris\_Zisis](https://community.opentargets.org/u/Dimitris_Zisis)\
**Post date:** [4 April 2023 16:39 UTC](https://community.opentargets.org/t/query-to-retrieve-studyid-from-variants-not-working/1037/1 "2023-04-04T16:39:03Z")

</div>

Hello,  
I want to use the following query in order to retrieve the stidyID associated with a variant ID.

```auto
query Variant {
  indexVariantsAndStudiesForTagVariant(variantId: "1_17500056_C_T"){
	associations {
    study {
      studyId
      pmid
    }
    indexVariant {
      id
      rsId
      refAllele
      altAllele
      nearestGeneDistance
    }
    pval
      
  }
  
}
	  }

```

After doing this i want to use the studyID and the variantID for the studyLocus2GeneTable. Unfortunately only the sample exaple of `indexVariantsAndStudiesForTagVariant` is working in the API but when i am trying different variantId i always get :

```auto
{
  "data": {
    "indexVariantsAndStudiesForTagVariant": {
      "associations": []
    }
  }
}

```

Why this is not working ?  
My plan is to try this query from R for multiple IDs. Is it possible to make it work?  
If not could you please provide me with an alternative for retrieving study IDs from variantId ?

---

<div class="post-metadata">

**Author:** ![Xiangyu](https://avatars.discourse-cdn.com/v4/letter/x/90db22/32.png) [@Xiangyu](https://community.opentargets.org/u/Xiangyu)\
**Post date:** [11 May 2023 16:02 UTC](https://community.opentargets.org/t/query-to-retrieve-studyid-from-variants-not-working/1037/2 "2023-05-11T16:02:12Z")

</div>

Hi Dimitris,

Hopefully the [discussion linked here](https://community.opentargets.org/t/downloading-variant-information/668/6) was helpful for your question.

Best wishes,  
Jack
