# Err code 500 with API using google app script lang

**URL:** <https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535>\
**Category:** GraphQL API\
**Created:** [June 21, 2023, 9:30am UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535 "2023-06-21T09:30:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![srob2](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@srob2](https://community.bitquery.io/u/srob2)\
**Post date:** [June 21, 2023, 9:30am UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535/1 "2023-06-21T09:30:01Z")

</div>

**script code in google app script lang with err in the last line (fetch func):**  
const API\_KEY = “BQ…Lv”

function MyTest(){

let query = ` query{ bitcoin{ blocks{ count } } } `;

let opts = {  
method: “POST”,  
headers: {“Content-Type”: “application/json”, “X-API-KEY”: API\_KEY},  
body: JSON.stringify(query)  
};

let response = UrlFetchApp.fetch(‘[https://graphql.bitquery.io](https://graphql.bitquery.io)’, opts)

}

**err mes:**  
Exception: Request failed for [https://graphql.bitquery.io](https://graphql.bitquery.io) returned code 500. Truncated server response: {“errors”:[{“message”:"undefined method `size' for nil:NilClass","backtrace":["/app/lib/util/requests_complexity.rb:10:in `pre\_calculate\_complexity… (use muteHttpExceptions option to examine full response)

help pls thanks

---

<div class="post-metadata">

**Author:** ![Divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Divya](https://community.bitquery.io/u/Divya)\
**Post date:** [June 21, 2023, 2:52pm UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535/2 "2023-06-21T14:52:12Z")

</div>

@srob2 thanks for bringing it to our notice. This seems to be an error on our side. Will get back to you soon with the fix.

---

<div class="post-metadata">

**Author:** ![Divya](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Divya](https://community.bitquery.io/u/Divya)\
**Post date:** [June 22, 2023, 12:52pm UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535/3 "2023-06-22T12:52:47Z")

</div>

@srob2 Here’s how we should use it:

```auto
let opts = {
    method: "post",
    muteHttpExceptions:true,
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": API_KEY,
    },
    payload: JSON.stringify({
      "query":query  
      ,"variables" : "{}"
  })
  };

```

set the query in the payload parameter and it works

---

<div class="post-metadata">

**Author:** ![srob2](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@srob2](https://community.bitquery.io/u/srob2)\
**Post date:** [June 22, 2023, 4:28pm UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535/4 "2023-06-22T16:28:39Z")

</div>

it works. thx

here is err in help info i used.  
fix it pls

> **[How to use GraphQL with Python, Javascript, and Ruby - Bitquery](https://bitquery.io/blog/graphql-with-python-javascript-and-ruby)**
>
> In the last few articles, we talked argued using GraphQL APIs for blockchain data and how to create your first blockchain GraphQL query. In this article, we will show how to call GraphQL APIs using different programming languages.

> [@Make API calls to Bitquery in Python, JavaScript, Dart, Golang and PHP](https://community.bitquery.io/t/make-api-calls-to-bitquery-in-python-javascript-dart-golang-and-php/1004):
>
> In this tutorial, we are going to make API calls to Bitquery using a variety of programming languages which have utility across all technology domain. Python Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small- and large-scale projects. Python is extensively used in :- AI and Machin…

---

<div class="post-metadata">

**Author:** ![miaco](https://sea2.discourse-cdn.com/flex016/user_avatar/community.bitquery.io/miaco/32/935_2.png) [@miaco](https://community.bitquery.io/u/miaco)\
**Post date:** [August 28, 2024, 12:48pm UTC](https://community.bitquery.io/t/err-code-500-with-api-using-google-app-script-lang/1535/6 "2024-08-28T12:48:57Z")

</div>

Hey…  
As per me, firstly you need to fix the url and correct the Query Syntax and then Update Your Fetch Call.  
I hope this will help you!
