Solved

REST with POST method reading AppSheet Database

  • 29 August 2023
  • 16 replies
  • 375 views

Userlevel 1

Yes, I’ve read the other posts about this topic

 

But I'm rather unlucky getting it to work. Each time I press the ‘Test Connection' it fires a GET method at the URI, which results in the infamous ‘The requested resource does not support http method 'GET'’ message.

 

RSD file:

==================================

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
    <api:info title="Table1" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
        <!-- You can modify the name, type, and column size here. -->
        <attr name="_RowNumber" xs:type="string" readonly="false" other:xPath="/json/_RowNumber"/>
        <attr name="Assignee" xs:type="string" readonly="false" other:xPath="/json/Assignee"/>
        <attr name="Date" xs:type="date" readonly="false" other:xPath="/json/Date"/>
        <attr name="Row_ID" xs:type="string" readonly="false" other:xPath="/json/Row ID"/>
        <attr name="Status" xs:type="string" readonly="false" other:xPath="/json/Status"/>
        <attr name="Title" xs:type="string" readonly="false" other:xPath="/json/Title"/>
    </api:info>
    
    <api:set attr="DataModel" value="DOCUMENT"/>
    <api:set attr="URI" value="https://api.appsheet.com/api/v2/apps/a92d1c56-938f-45ac-bc00-c637f37a1a60/tables/Table%201/Action"/>
    <api:set attr="JSONPath" value="$."/>
    
    <!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
    <api:script method="GET">
        <api:set attr="method" value="POST"/>
        <api:set attr="contenttype" value="application/json"/>
        <api:set attr="data">{"Action": "Find","Properties": {"Locale": "nl-NL"}}</api:set>
        <api:call op="jsonproviderGet">
            <api:push/>
        </api:call>
    </api:script>
</api:script>
================================

 

Instructions how to read a AppSheet  Database: https://support.google.com/appsheet/answer/10105770?hl=en

 

I got it to work in Postman (please develop a postman import-functionality btw, that would make life so much easier!)

POST URI call
API Key in header
raw body data

 

icon

Best answer by Thomas Lind 30 August 2023, 11:16

View original

16 replies

Userlevel 6
Badge +5

Hi @mnoordam 

I set up my own app in Appsheets to see if I got the same issues.

Here is the file I generated.

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="response" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
<!-- You can modify the name, type, and column size here. -->
<attr name="_RowNumber" xs:type="string" readonly="false" other:xPath="/json/_RowNumber" />
<attr name="Category" xs:type="string" readonly="false" other:xPath="/json/Category" />
<attr name="ID" xs:type="string" readonly="false" other:xPath="/json/ID" />
<attr name="Last_Edited" xs:type="datetime" readonly="false" other:xPath="/json/Last Edited" />
<attr name="Last_Edited_By" xs:type="string" readonly="false" other:xPath="/json/Last Edited By" />
<attr name="Name" xs:type="string" readonly="false" other:xPath="/json/Name" />
<attr name="Picture" xs:type="string" readonly="false" other:xPath="/json/Picture" />
<attr name="Related_List_Contents" xs:type="string" readonly="false" other:xPath="/json/Related List Contents" />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="URI"value="https://api.appsheet.com/api/v2/apps/bee87e8e-6af5-4bec-a598-92efe436868d/tables/Items/Action?ApplicationAccessKey=V2-7vA2m-wx869-5d3fo-Nzy1s-dp6Ny-1234-56789-abcd" />

<api:set attr="JSONPath" value="$." />

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="POST"/>
<api:set attr="contenttype" value="application/json"/>
<api:set attr="data">{"Action": "Find","Properties": {"Locale": "en-US"}}</api:set>
<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>

</api:script>

It works for me. The only difference is that I have the ApplicationAccessKey set as an URL parameter instead of an header.

UPDATE

It works for me no matter if I have set up the header in my data source or added it. I think it is something else, but it is not about it not being able to do post calls.

Userlevel 1

Hi Thomas,

Then I must surely have set something wrong in the Datasource settings.

I've replaced my RSD with yours and made a new ODX-Datasource

 

URI = https://api.appsheet.com/api/v2/apps/bee87e8e-6af5-4bec-a598-92efe436868d/tables/Items/Action?ApplicationAccessKey=V2-7vA2m-wx869-5d3fo-Nzy1s-dp6Ny-1234-56789-abcd

Schema locatie = <directory which contains RSD file>

Table = Name of RSD-file

 

ATTEMPT 1

→ TEST CONNECTION = Failed - Method not allowed


ATTEMPT 2

Authenticatie → Basic + username/pwd

→ TEST CONNECTION = Failed - Method not allowed

 

What does your datasource settings look like?

Userlevel 1

This is my log

Userlevel 6
Badge +5

My setup is very basic, I only use the Location field and the Custom Headers one.
 

Once I generated my RSD file, I reset the URI and Generate Schema File fields.

The way I always do it with POST issues, is that I start by getting it to work in Postman, then I save the result as a response.json file which I use to generate the RSD file with.

Userlevel 1

I did exactly the same. Postman works like a charm, 

postman Results → TX → generated new RSD → Edit URI

 

You do use the REST 2023 driver?

 

 

Userlevel 1

@Thomas Lind 
Can you try with my URI?
https://api.appsheet.com/api/v2/apps/a92d1c56-938f-45ac-bc00-c637f37a1a60/tables/Table%201/Action

applicationAccessKey: V2-096rT-1Aa8M-TINzx-11BcG-UJm6z-HYqxP-9YcRT-6XEYr

 

Userlevel 6
Badge +5

I try to always use the newest available version the newest one currently is 23.0.8565.0

I tried both the REST one and the JSON one and they both behaved the same way.

If you connect with the Response.json file it works with no issues right?

 

I will try yours.

Userlevel 1

Yeah, no problem importing your response.json and generating a RSD-file out of that.

 

Userlevel 6
Badge +5

Hi @mnoordam 

I have made a file where the header is directly applied in the setup. This works for me.

Let me know if it works for you as well.

You can’t upload RSD files to this, so I have added an extra .txt to the file, remember to remove this before it can be used.

Userlevel 1

What does your logfile look like?

Userlevel 1

….

Userlevel 1

Either it's time for new glasses or a new career. I can’t find anything that would explain why it;s working on your site but not on mine.

Userlevel 6
Badge +5

You can reset the fields like shown in this gif.

That is the only differences between our setups that I can see.

Userlevel 1

I did that.+ Created a new DataSource, both cases the same ‘GET-method’- error
I'm running ODX version 20.10.41, you probably on the latest (20.10.43)?
Though I read nothing about REST-API/connection changes in the releasenotes, should I upgrade my environment?

Userlevel 1

HOLDUP. It works!
I did a reset + supplied the URI again.

But you meant deleting the whole URI. That was it. So simple. :-|

 

Thx for yoru assistance!!

 

Userlevel 6
Badge +5

@mnoordam 

I did not think of it as an issue before now, but yeah, I that explains it.

Essentially it will not work when an URI is applied because it will then expect it to be a GET call, whereas we control this in the file.

Reply