Error when creating an FHIR resource in google cloud healthcare API (Ruby) - ruby

I'm trying to create a Patient type resource using the service
healthcare = Google::Apis::HealthcareV1
service = healthcare::CloudHealthcareService.new
and create_project_location_dataset_fhir_store_fhir method in ruby.
I keep on getting this error
missing required field: resourceType
more details on the function im using: https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/HealthcareV1/CloudHealthcareService.html#create_project_location_dataset_fhir_store_fhir-instance_method
if anyone has come across this and knows how to fix it
this is how i create my request body:
http_body_object = Google::Apis::HealthcareV1::HttpBody.new
http_body_object.content_type = "application/fhir+json"
http_body_object.data = json_encoded
http_body_object.extensions = extensions

The body could be missing the proper resourceType: Patient as you can find at this link - hl7.org/fhir/patient-example.json.html

Related

How do I create an invitation to a class using the invitations.create() method?

I'm using the Google Classroom API with Python, and am trying to invite a student to a course, using the invitations.create() method. However, I keep getting a "404 requested entity not found" error, and I'm unsure what's causing it.
service = build('classroom', 'v1', credentials=creds)
info = {
"userId": "zariftwitters#gmail.com",
"courseId": "117906298438634973718",
"role": "STUDENT"
}
i = service.invitations().create(body=info).execute()
Error message:
Http Error 404 when requesting
https://classroom.googleapis.com/v1/invitations?alt=json returned
"Requested entity was not found."
Most likely it means that the course Id is incorrect
The course Id should contain 11 numbers.
You can list all courses and their Ids with the method courses.list, the easiest way to do it would be with the Try this API.

list_comments Ruby implementation with YouTube video_id

Having trouble implementing the list_comments method in the following code example (n.b. the API is initialised successfully):
# initialize API
service = Google::Apis::YoutubeV3::YouTubeService.new
service.client_options.application_name = APPLICATION_NAME
service.authorization = authorize
response = service.list_comments('snippet, replies')
Currently the method returns the following error:
missingRequiredParameter: No filter selected. Expected one of: id, idParam, parentId (Google::Apis::ClientError)
I have successfully tested the API call here:
https://developers.google.com/youtube/v3/docs/comments/list
What I'm struggling with is when I test the API call I can pass a videoId to identify a resource, however the method implementation does not allow for this. Could anyone shed some light on how to pass a videoId to the method call?
Found the solution! The method that allows you to specify video_id (or channel_id) to select a specific resource is: list_comment_threads from the Google::Apis::YoutubeV3::YouTubeService module.
response = service.list_comment_threads('snippet', video_id: 'hy1v891n3kA').to_json

Adwords API getting customerId

I have an adwords user's Oauth credentials, and I'm able to successfully make an API call to download a report, but I had to hard-code in the customerId as I couldn't figure out how to get it.
The get() method of the CustomerService in the API should return the customer ID, but what are the parameters to pass to it?
I tried a GET request to this URL
without any header params or body params, to which it returns:
"<html><body>No service was found.</body></html>".
I also tried with an Authorization and developerToken defined in the headers, but got the same response.
I also tried the python library, and defined an instance of AdWordsClient like this, but it's client_customer_id variable ends up as None:
from googleads.adwords import AdWordsClient
oauth_client = GoogleRefreshTokenClient(environ.get('GOOGLE_CLIENT_ID'), environ.get('GOOGLE_CLIENT_SECRET'), oauth_record.refresh_token)
adwords_client = AdWordsClient(environ.get('ADWORDS_DEVELOPER_TOKEN'), oauth_client, user_agent='agent'))
customer_id = adwords_client.client_customer_id
print 'customer_id:' + str(customer_id)
Unlike this question, I don't care about adding the user to my MCC account.
Here is how to get the customer ID with the googleads-python-lib library:
oauth_client = GoogleRefreshTokenClient(environ.get('GOOGLE_CLIENT_ID'), environ.get('GOOGLE_CLIENT_SECRET'), oauth_record.refresh_token)
adwords_client = AdWordsClient(environ.get('ADWORDS_DEVELOPER_TOKEN'), oauth_client, user_agent='your_user_agent_here')
customer = adwords_client.GetService('CustomerService').get()
customer_id = customer['customerId']
from googleads import oauth2, adwords
oauth_client = oauth2.GoogleRefreshTokenClient(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, refresh_token)
adwords_client = adwords.AdWordsClient(ADWORDS_DEVELOPER_TOKEN, oauth_client, user_agent='your_user_agent')
customers = adwords_client.GetService('CustomerService', version='v201809').getCustomers()
print(customers['customer_id'])

Error while calling google+ method plusService.People.Get

The Google+ API is set to "On" from google's developer console. I am fetching the profile information of the user by supplying the api key but I get an error saying:
Access Not Configured. Please use Google Developers Console to activate the API for your project. [403]
BaseClientService.Initializer ini = new BaseClientService.Initializer { ApiKey = "" };
PlusService plusService = new PlusService(ini);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person googleUser = prgr.Execute();
}
The error is thrown when Execute is called.
Does this service needs to be set up with "billed" profile ? This may be the reason I am getting access error.
The "me" argument only works when you have an authenticated user's OAuth 2.0 access token. Simple API access with a key only allows access to public data - try putting in a numeric user id instead of me and you should get a response.

palm webOS MailService parameter passing problem

i am developing an application in palm webOS. In that application i have to use the MailService to send mail directly without opening any of the email or compose scenes. For that i have to pass params. But i don't know how to pass the params and what params i have to pass to tha MailService.
params.to ="mailId#abc.com";
params.subject = "subj";
params.msg = "message";
this.controller.serviceRequest('palm://com.palm.mail.MailService', {
method: 'messageSend',
parameters: params,
onSuccess: this.messageSentCallback,
onError: this.messageErrorCallback
});
But i am getting error of " Uncaught TypeError: Cannot set property 'to' of undefined,"
can you help me to resolve this problem please.
ThanQ for all.
This looks like a basic Javascript error. Did you put a line like "var params = {};" first to declare the params variable as an empty object?
Do note -- sending email using the service requires that your app access the private system bus as a com.palm.* application. This means you won't be able to distribute via the App Catalog.

Resources