Power Query M - Expression Error - list to text - json

I'm doing a API request using Web.Contents. I submit a dynamic access token, which I get from a function.
let
Source =
Json.Document(
Web.Contents(
{"https://api-url.com/endpoint/id"},
[Headers=[Authorization="Bearer "& GetToken()]]))
in Source
This works in all of my other instances, but for some reason I get an error with a specific endpoint, to which I submit a id. The error is:
Expression.Error: We cannot convert a value of type List to type Text.
Details:
Value=[List]
Type=[Type]
I have checked the documentation for the API, and the response is composed of the following
id - Id of the device
lastServicedDate - The last time the service was done.
trip -
total -
stateLastUpdated - the timestamp of the state.
Previous assistance have informed me that I need to expand the list, but I cannot seem to make this work.
Any assistance is highly appreciated. Thank you.

You are supplying a list to Web.Contents instead of text. {} denotes a list. Remove your braces:
Web.Contents(
"https://api-url.com/endpoint/id",
[Headers=[Authorization="Bearer "& GetToken()]])

Related

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

How to retrieve a single contact with gdata? Getting a 'not supported' error

I'm copying the code here https://developers.google.com/google-apps/contacts/v3/#retrieving_a_single_contact.
And here's my code:
Dim cr = ContactAuthentication()
Dim groups = GetGroups(cr)
Dim entry As Contact
entry = cr.Retrieve(Of Contact)(New Uri("https://www.google.com/m8/feeds/contacts/default/full/38B2D4F80D96B2C2"))
On the last line, it falls with the following error:
Google.GData.Client.GDataRequestException: 'Execution of request
failed:
https://www.google.com/m8/feeds/contacts/default/full/38B2D4F80D96B2C2?max-results=100'
"The 'max-results' parameter is not supported on this
resource"
Which is odd, since I never put in a max result parameter. Also, if it makes any difference, the Google docs show an example that takes a string url as the param for Retrieve. I could not find such an overload, the closest is what I put here, using a Uri
Anyone have any ideas how I can retrieve a single contact by id for updating?
Thanks!
You may refer with this documentation: Retrieving a single contact. To retrieve a single contact, send an authorized GET request to the contact's selfLink URL:
https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}
With the appropriate values in place of userEmail and contactID. Be noted that the special userEmail value default can be used to refer to the authenticated user.
And as referred with this post, maybe you had setting.Pagesize = 100, which caused your uri to be https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}?max-results=100.
Hope this helps!

Enummerate Field Names In Swagger

So I have done some hunting around online, and have been able to figure out how to use the enum tag in a swagger doc to specify a list of possible values for a field. However, in my current API what I need instead is to have a list of potential fields, each of which has a string value.
To be more precise, I have a POST request that sends JSON in the request body. As part of this request users need to send a single ID field. However, we accept multiple types of ID fields. So the request would look something like this:
{name:"name", product:"product", [FirstIdType, SecondIdType, ThirdIdType]:"ID Value"}
So I need to have the user submit a JSON that has a name, product, and one of FirstIdType, SecondIdType, or ThirdIdType. Technically it is required to have exactly one of those three ID types in the request, but I don't really mind if that isn't possible in the swagger doc. Noting it in the description for the field is fine.
The other constraint is that I can't really change the design at this point. The app has already been built using this design and changing it is out of my hands. Which means that I can't just make an array of ID Types and then choose one of them.
Here is the relevant bit from my swagger doc. The area that needs changed is the ID field. Any thoughts or directions on how to get that to go forward would be really appreciated.
definitions:
request_post:
description: (post) request schema
properties:
name:
type: string
product:
type: string
Id:
type: string
Instead of defining what optional fields can come on the path, you can label the fields that are required and make the rest variable by default.
http://swagger.io/specification/#parameterObject
required boolean Determines whether this parameter is mandatory. If
the parameter is in "path", this property is required and its value
MUST be true. Otherwise, the property MAY be included and its default
value is false.

Current Field Value into a VBA String Programmatically

I need to take the current value of a field from the record displayed on an open Access form and put the text in that field into a VBA string programmatically. This seems so simple but I have not yet been to find any guidance from either an aftermarket Access 2013 text I purchased or the Internet. I have tried everything I can think of with no success whatsoever so I posted a question on stackoverflow.com and received the following suggested solution:
Dim strYourString as String
strYourString = Forms![Your Form Name].[Field Name].Value
When this is run I get:
Runtime error ‘438’
Object doesn’t support this property or method
Any help will be greatly appreciated!
Try using a bang symbol in front of the field name, instead of a period.
strYourString = Forms![Your Form Name]![Field Name].Value
^---------------------Bang symbol here
This is supported by the documentation here on MSDN. Note the implicit form:
Forms!OrderForm!NewData
where NewData is the name of a control. Or you can use an explicit reference:
Forms!OrderForm.Controls!NewData
If you want to refer to a field in the underlying recordset of the form instead, use:
Forms!MyForm.Recordset.Fields("MyFieldName")

Box API: Get_managed_users returning all users

Using the Box 1.0 REST API, I am trying to work with the functions in SOAP UI.
The API doc for get_managed_users with user_id=12345 (internal id retrieved with get_user_id call correctly) is returning all the users. The docs say that would be the case if you do not specify a user_id value. But my full command is: (Token and API key changed to protect the clueless)
https://www.box.com/api/1.0/rest?user_id=27360&auth_token=blahbalhblah1234&action=get_managed_users&api_key=someKeyYouShouldNotSee
Now I could work with the complete result list, but that won't scale as we get thousands of users into the system.
I can make a call with edit_managed_user, using the same user_id value and the change is reflected in the UI, and in the next get_managed_users call. Thus I do have the correct user_id value, I would so assume.
I tried testuser#gmail.com as the user_id value as well, and get the entire list back. This leads me to believe that somehow I am sending user_id wrong, but I just do not see it.
Any hints? Why, with what seems like a valid user_id value is it acting like it is absent or incorrect?
Most likely you have either called this method with an invalid user_id, or one that is not in your set of managed users. Can you double check that the user comes back in your list of already managed users?