Update event - Side case update BODY - microsoft-graph-api

The https://graph.microsoft.com/v1.0/me/events/{id} call in PATH for the body update generates an unpleasant case.
The event created as onlineMeeting with provider Teams if the body is updated, all attendees are sent the invitation as a non-online event. It will be necessary to redo the UPDATE call to re-create the event as onlineMeeting with the updated body.
Thx

For ‘Create Event’ API, user need to explicitly pass ‘isOnlineMeeting’ field and set it to ‘true’ to ensure an online meeting is created.
For e.g. –
{
...
"allowNewTimeProposals": true,
"isOnlineMeeting": true,
"onlineMeetingProvider": "teamsForBusiness"
...
}
Refer to example 4 of the documentation to create an event as an online meeting.
Please let me know if this helps.

Related

How to Update Envelope Custom Fields of Docusign Envelope In process, with rest API in RoR

I am trying to update a Custom field in a envelope that I have already sent.
Request URL: #https://demo.docusign.net/restapi/v2/accounts/1976929/envelopes/21d46fc6-8bbe-4315-b606-47cfd0ee0e3c/custom_fields>
Request Body:
"{\"textCustomFields\": [{\"name\":\"customer_email\",\"value\":\"new_email#new.com\",\"show\":\"true\",\"required\":\"true\"}]}"
Response:
{"textCustomFields"=>
[{"fieldId"=>"10198325521", "name"=>"customer_email", "show"=>"true",
"required"=>"true", "value"=>"new_email#new.com",
"errorDetails"=>
{"errorCode"=>"CUSTOM_FIELD_ALREADY_EXISTS", "message"=>"Field Name:
customer_email"}}], "listCustomFields"=>[]}
I am trying to update the value of custom field 'Customer Email'
the response I get is Custom Field Already exist.
The use case if that if by mistake the envelope has been sent to wrong email, we'd like to update the already sent envelope with this new email and resend it.
I am on Ruby on Rails.
If initially I sent the envelope with a custom text field value old_email#email.com.
Now I would like to see the value changed to new_email#email.com
Are you using a PUT or a POST? Should be a PUT.
Also, you only need to specify "FieldId", "name", and "value".
{
"textCustomFields": [{
"fieldId": "10210399758",
"name": "customer_email",
"value": "new_email#new.com"
}]
}

Microsoft Graph API: "responseRequested" Attribute in "Update Event" does not work

As written in Microsoft Graph documentation, Event update endpoint allows responseRequested as one of the input property. It says:
Set to true if the sender would like a response when the event is
accepted or declined.
I tried setting it to false and I'm expecting it to have similar behavior with "Request responses" button in the UI. Unfortunately, it does not work as I'm expecting it to behave.
For example, in the web UI, if you turn "Request responses" off, no notification will be sent to the attendees and a message that shows no attendance response is required.
UI Screenshot
UI Screenshot - Expected behavior
For the code itself:
type UpdateEventRequest struct {
ResponseRequested bool `json:"responseRequested,omitempty"`
End *DateTimeTimeZone `json:"end,omitempty"`
}
type DateTimeTimeZone struct {
DateTime string `json:"dateTime,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
}
func NewDateTimeTimeZone(t time.Time) *DateTimeTimeZone {
return &DateTimeTimeZone{
DateTime: t.Format("2006-01-02T15:04:05.999999"),
TimeZone: t.Location().String(),
}
}
When I tried to update an event to the following:
&UpdateEventRequest{
ResponseRequested: false,
End: NewDateTimeTimeZone(newEventEndTime),
}
Event end time is updated properly to newEventEndTime. However, ResponseRequested doesn't seem to update anything.
Am I missing something here? My initial goal is to change event end time via API without requiring attendance to submit "Yes/No" response. Thanks.

Jira issue status not getting updated

I am trying to update Jira issue fields through REST Api, I am able to update summary, description, priority, reporter fields but the status.
Here is the code I am trying to run:
string jSonContent = (#"
{
""fields"": {
""summary"": ""data"",
""description"": ""modified."",
""priority"": {""name"": ""val""},
""reporter"": {""name"": ""abcdef#gmail.com""},
""status"": {""name"": ""WORK IN PROGRESS""}
}
}").Replace("data", summ).Replace("modified.", desc).Replace("val", pri);
request.AddParameter("application/json", jSonContent, ParameterType.RequestBody);
var response = Execute(request);
You cannot change the status of an issue the way like that.
To determine what type of fields could be changed with a simple PUT request do a GET for metadata:
https://{your-jira-url}/rest/api/2/issue/{issueIdOrKey}/editmeta
This query in turn will provide you all the fields that you can modify. You won't find status field in the returned JSON object.
Back to your problem: How could be the status of an issue changed? In Jira you have a workflow that holds the possible transition between the states. In order to change the state you need to do a transition. (Exactly the same way as you would do it on UI.)
So first do a GET request like that:
https://{your-jira-url}/rest/api/2/issue/{issueIdOrKey}/transitions?expand=transitions.fields
This request will return all possible transitions of your issue's current state. Check which transition you want to perform and note it's ID (in my case the wished ID is 11). With this transition ID you can do a POST request with the JSON payload:
https://{your-jira-url}/rest/api/2/issue/{issueIdOrKey}/transitions
{
"transition": {
"id": "11"
}
}
One additional thing to note: If your transition isn't a simple one then you have to provide more data. I mean a simple transition here where you simply would click on a button on the UI and you wouldn't get an extra screen for the transition. (E.g. you can setup a transition like: you only could resolve an issue if you add a comment to it.) Fortunately, the previously returned transition list contains all the fields that could or that must be provided together with the transition ID.
You can find more information in official Jira documentation.

Retrieve Customer's default and active card from Stripe

I am trying to retrieve the default and active card of a Customer. (Also keep in mind that with the coding I have, the customer can always have one card which means if there is a way around it it can help).
Some months ago I used this code segment which was working fine. It seems Stripe made some updates and I can't get it to work now.
current_user.stripe_card_id = customer.active_card.id
The error I get is
undefined method `active_card' for #Stripe::Customer
If you need any more information please let me know.
edit: customer.default_card.id does not work either.
I used customer.methods to check the methods and found this (default_source):
current_user.stripe_card_id = customer.default_source
Works fine now. Thank you
default card id will available in customer object's "default_source" key
{
"id": "cus_GACkqbqFD8RQw4",
"object": "customer",
"default_source": <DEFAULT CARD ID HERE>
...
}
read more here : https://stripe.com/docs/api/customers
[EDIT] Additionally,
It's worth noting that when you request a list of all the cards belonging to a particular customer, the default card is always at the top of the result. So you could also get the default card by requesting the customers cards and adding a limit of 1.
Information on how to achieve this: https://stripe.com/docs/api/cards/list
PaymentMethods API - 2020 update
If you have switched from old Sources API to the new Payment Methods API then you should know that unlike old Sources there's no default Payment Method for a Customer.
Now, you can attach a Payment Method as default one to a subscription object:
Stripe::Subscription.update(
'sub_8epEF0PuRhmltU',
{
default_payment_method: 'pm_1F0c9v2eZvKYlo2CJDeTrB4n',
}
)
or as a customer.invoice_settings.default_payment_method
Stripe::Customer.update(
'cus_FOcc5sbh3ZQpAU',
{
invoice_settings: {default_payment_method: 'pm_1vvc9v2eZvKYlo2CJDeTrB4n'},
}
)
Here is the whole Stripe documentation on that
Relying on customers' default_source is safe no matter the changes. You can see here that subscriptions will still use customers' default_source if both invoice_settings.default_payment_method and subscription.default_payment_method are not set.
customer = Stripe::Customer.retrieve(customer_id_on_stripe)
first_3_cards = customer.sources.all(limit: 3, object: 'card')[:data]
Will return array of cards, if you want to fetch bank_accounts
first_3_bank_accounts = customer.sources.all(limit: 3, object: 'bank_account')[:data]

Put_connections to create a new event with Koala?

I'm trying to create a new event using the Koala gem and it's returning with the same error I got when I tried to update an event with an incorrectly formatted datetime value.
I can update just fine now but still cannot create an event.
Here's the code I use on my update method which works:
start_time = safe_params[:start_time].in_time_zone
end_time = safe_params[:end_time].in_time_zone
graph.put_connections(safe_params[:fb_id], "event", {
name: safe_params[:name],
description: safe_params[:description],
privacy: safe_params[:privacy]
})
And here's the code I'm trying to use to create a new event object:
graph.put_connections("/me/events", "event", { #this is the line that errors
name: safe_params[:name],
description: safe_params[:description],
privacy: safe_params[:privacy]
})
According to Facebook's documentation on creating an event (https://developers.facebook.com/docs/graph-api/reference/user/events/), I should be able to create a new event just by initiating a post to /me/events. Anyone have any idea?
I also tried:
graph.put_connections("/"+current_user.fb_id.to_s+"/events", "event", {
Thanks!
What happens if you do something like this?
graph.put_connections("me", "events", {
name: safe_params[:name],
description: safe_params[:description],
privacy: safe_params[:privacy],
start_time: ...,
end_time: ...
})
So after messing with Facebook's Graph Explorer and attempting hundreds of different combinations with put_connections I decided to make a straight graph_call using Koala.
Finally got an ID response back. I almost cried. Thought I'd share with the community in case there's someone else trying to do the same thing.
event_response = graph.graph_call("/me/events",{
name:safe_params[:name],
start_time: safe_params[:start_time],
privacy_type: safe_params[:privacy],
access_token: current_user.oauth_token}, "POST")
safe_params[:fb_id] << event_response["id"]
#event = Event.create safe_params
I make the call in a stored variable event_response because the Facebook Id returned is used in my app.
First thing I found out: despite using "privacy" as the name of the privacy field when GETting from Facebook and saying so in their documentation, "privacy_type" is actually what you want (found this out in another SO post).
The second thing I found out is even though you are authenticated (have a user token) when you make a graph_call you STILL need to pass along the current_user access token along with making a POST graph_call.
Hope this helps someone!

Resources