Hello,

I'm trying to get the content of a sharepoint list. The list has 145 elements but when I tes my request with outsystems, I got no item...

so if I test with the REST Method:

https://testsp.sharepoint.com/sites/Collaboration/MD/_api/web/lists/GetByTitle('OEM_Short_ID')

I get:

{
  "d": {
    "__metadata": {
      "id": "https://testsp.sharepoint.com/sites/Collaboration/MD/_api/Web/Lists(guid'501be800-c650-4549-9a05-85ac2c08d131')",
      "uri": "https://testsp.sharepoint.com/sites/Collaboration/MD/_api/Web/Lists(guid'501be800-c650-4549-9a05-85ac2c08d131')",
      "etag": "\"81\"",
      "type": "SP.List"
    },
...
    "Items": {
      "__deferred": {
        "uri": "https://testsp.sharepoint.com/sites/Collaboration/MD/_api/Web/Lists(guid'501be800-c650-4549-9a05-85ac2c08d131')/Items"
      }
    },
...
    "AllowContentTypes": true,
    "BaseTemplate": 100,
    "BaseType": 0,
    "ContentTypesEnabled": false,
    "CrawlNonDefaultViews": false,
    "Created": "2018-04-10T13:33:46Z",
    "CurrentChangeToken": {
      "__metadata": {
        "type": "SP.ChangeToken"
      },
      "StringValue": "1;3;501be800-c650-4549-9a05-85ac2c08d131;636887794655170000;303275688"
    },
    "DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
    "DefaultItemOpenUseListSetting": false,
    "Description": "",
    "Direction": "none",
    "DisableGridEditing": false,
    "DocumentTemplateUrl": null,
    "DraftVersionVisibility": 0,
    "EnableAttachments": true,
    "EnableFolderCreation": false,
    "EnableMinorVersions": false,
    "EnableModeration": false,
    "EnableRequestSignOff": true,
    "EnableVersioning": true,
    "EntityTypeName": "OEM_x005f_Short_x005f_IDList",
    "ExemptFromBlockDownloadOfNonViewableFiles": false,
    "FileSavePostProcessingEnabled": false,
    "ForceCheckout": false,
    "HasExternalDataSource": false,
    "Hidden": false,
    "Id": "501be800-c650-4549-9a05-85ac2c08d131",
    ...
    "ItemCount": 145,
    ...
    "Title": "OEM_Short_ID"
  }
}

as you can see, the value of ItemCount is 145

but the method:

https://testsp.sharepoint.com/sites/Collaboration/MD/_api/web/lists/GetByTitle('OEM_Short_ID')/Items

returns:

{  "d": {    "results": []  }}

For info, if I type this URL in my browser I get all 145 items

Do you know why?

Can someone help me?

Thanks in advance

Vincent

Hi,

CrossCheck your Response Structure.

Based on your browser response the high-level structure for JSON is:

{

"d":{

   "_metadata":{

      }

  }

}


But If you see what you mention for Outsystem Output is not same.

Goto the Consume REST API Interface & Test it once again & Copy the Response Structure from TEST-Response to Body-Response.

The issue is of the Structure. You can also debug the API Call on Browser.

Run you App on Browser & Goto Inspect-Network

This way you can debug the Response you are getting from API

Thanks

Assif

Hi Vincent ,

Did you check service center logs ? Check if you can see any error there. Also match your structure with the response and see if the attributes are  properly mapped .


Regards,

-PJ-


I think Assif is right here, your Structure probably doesn't match the output. Also, if you want to check whether you receive the data at all, see this post.

Thanks for all your answers!!

I not a specialist of REST and json...

to explain, I have these results with the Test function of the REST API interface and I didn't create any structure for the response yet...

So this is the result I have in the Response field of the REST API Interface.

I will try to check all your advice to see if I have forgotten something

Hi,

You do not need to create the Response Structure for the JSON.

OutSystem will Automatically create the REST API Request & Response Structure based on what you provided in Body

Note: 

-Make sure to copy the Success Response Structure only in Body instead of any error or False Response

-Consume API with the Request params which response with successful data.

Ref Documentation to learn more about REST API Consume:

https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Consume_REST_APIs/Consume_a_REST_API


Thanks,

Assif

Hello all,

For information, I'm not able to get succesful answer from the consume REST API Interface...

I have correct answer if I copy/paste the REST request in the browser.

Il the console monitoring, I have no error, I just see {"value":[]}...

It's about a sharepoint list so I created a client Id and client secret for my application, I generate a Token for the authorization and I use this token for the REST request

Did someone already did this?

If yes, how was he able to get result?

Thanks in advance

Hi,

Can you specify more clearly coz it's not clear what you are using the request & what you got.

You can share the screenshot or can message me the request, hope I can help you to consume the same.


If it is a kind of API which serves the request using the same HTTP Request object in terms of authorization then simple Outsystems REST API is not going to help you, rather you have to create a custom integration. I have faced this type of issue in past & resolved the same by creating Integration.


- assif

@assif: Vincent has a correct response in the browser, so I would think no custom integration is needed.

@Vincent: You say it works in the browser - does it also work with the Test REST functionality in the REST pop-up? And does it work with another tool, like Postman?

Thanks for your answers!

What I do is very simple: I try to get a list of sharepoint using the REST consume interface of outsystems.

The REST query is:

https://testsp.sharepoint.com/sites/Collaboration/MD/_api/web/lists/GetByTitle('OEM_Short_ID')/Items

- When I copy paste this request directly in the address bar of my browser, I got the correct answer.

- When I test this request in the REST Popup with the test button, I get this:


But I know that the list is not empty because and my connection is ok because I can ask for the itemcount of this list and I got the correct number of items:


That's why I don't understand why I cannot have the list content...

Vincent

Hi Vincent,

I still don't understand how you can get the "correct answer" when using the browser, since it won't have the authorization token in the header, so you shouldn't have a valid reply (more like a 403 Forbidden or the like).

That said, you may need to supply some additional information to the Items call, like the $select mentioned here, or perhaps some parameters for paging.