Closed amarbut24 closed 2 years ago
Hi @amarbut24 , Thanks for reaching out and for using the Go SDK. Please have a look at this answer and let us know if you have any questions.
Hey @baywet
Thanks for the super quick response and all the work on this SDK. Apologies for not catching the other post/answer.
I've given it a try and am running into a different error
Code
graphClient.GroupsById(group.ObjectID).Members().Post(reference)
Error (this is presenting itself in VSCode)
graphClient.GroupsById(group.ObjectID).Members().Post undefined (type *"github.com/microsoftgraph/msgraph-sdk-go/groups/item/members".MembersRequestBuilder has no field or method Post)
I made sure I ran go get github.com/microsoftgraph/msgraph-sdk-go@v0.26.0
and updated my .mod file
require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
github.com/microsoft/kiota-authentication-azure-go v0.3.1
github.com/microsoftgraph/msgraph-sdk-go v0.26.0
github.com/microsoftgraph/msgraph-sdk-go-core v0.26.1
)
Hey @baywet
Please disregard my previous comment. I mistakenly read your comment in the previous thread and wasn't including the .Ref()
method in my call
Everything is working now
I take that back 😞
If I use r, err := graphClient.GroupsById(group.ObjectID).Members().Ref().Post(reference)
I get the interface error
If I try and use r, err := graphClient.GroupsById(group.ObjectID).Members().Post(reference)
I'm told that graphClient.GroupsById(group.ObjectID).Members().Post undefined (type *"github.com/microsoftgraph/msgraph-sdk-go/groups/item/members".MembersRequestBuilder has no field or method Post)
Sorry if I'm doing something dumb
@baywet despite #155 been closed and marked as resolved this is still very much an issue and not working as of release 0.26.0
To recap, I have the following code (similar to @amarbut24) and I continue to get the error below:
requestBody := ref.NewRef()
oDataLink := fmt.Sprintf("https://graph.microsoft.com/v1.0/directoryObjects/%s", userId)
requestBody.GetAdditionalData()["@odata.id"] = oDataLink
_, err := graphClient.GroupsById(group.Id).Members().Ref().Post(requestBody)
where ref.NewRef()
is imported from "github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref"
Error from invoking the above code snippet:
panic: interface conversion: interface is nil, not ref.Refable
goroutine 1 [running]:
github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).PostWithRequestConfigurationAndResponseHandler(0xc00055a5e8, {0x37e3b48?, 0xc000006058?}, 0xa?, 0x2?)
C:/Users/bjoseph/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.26.0/groups/item/members/ref/ref_request_builder.go:144 +0x11e
github.com/microsoftgraph/msgraph-sdk-go/groups/item/members/ref.(*RefRequestBuilder).Post(...)
C:/Users/bjoseph/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.26.0/groups/item/members/ref/ref_request_builder.go:128
I also tried the workaround of using the RequestBuilder directly and that also failed with a go panic error, code snippet and error below:
url := fmt.Sprintf("https://graph.microsoft.com/v1.0/groups/%s/members/$ref", group.Id)
requestBuilder := groups.NewGroupsRequestBuilder(url, graphClient.requestAdapter)
objectToAdd := models.NewGroup()
objectToAdd.GetAdditionalData()["@odata.id"] = oDataLink
_, err := requestBuilder.Post(objectToAdd)
Error from invoking the above code snippet:
panic: interface conversion: interface is nil, not models.Groupable
goroutine 1 [running]:
github.com/microsoftgraph/msgraph-sdk-go/groups.(*GroupsRequestBuilder).PostWithRequestConfigurationAndResponseHandler(0xc00081e5e8, {0x398aed0?, 0xc000261400?}, 0x9?, 0x1?)
C:/Users/bjoseph/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.26.0/groups/groups_request_builder.go:169 +0x11e
github.com/microsoftgraph/msgraph-sdk-go/groups.(*GroupsRequestBuilder).Post(...)
C:/Users/bjoseph/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.26.0/groups/groups_request_builder.go:153
@baywet Is it possible to get an ETA on this issue and #155, which I believe are both affected by the same underlying bug. This is an Active blocker preventing us from making further progress.
Hey everyone, Thanks for your patience on this matter, I was out all of last week being sick.
I've provided a reply to #155 here for the details. I'll circle back with the dev who owns the conversion library to get things pushed forward. No ETA to share at the moment.
Hey @baywet
thanks for the follow up and I hope you are feeling better. I've gone ahead and subscribed to https://github.com/microsoft/OpenAPI.NET.OData/issues/228 in the meantime
Thanks for the update @baywet, and hope you're feeling better. I will also keep an eye on the progress of https://github.com/microsoft/OpenAPI.NET.OData/issues/228
yep, it's progress in the right direction. Now the conversion library still needs to be released, then hidi, the tool we're using for the conversion needs to grab this new release, and get released itself. And finally we'll be able to generate a new version of the Go SDK, which should include those fixes. Hopefully by next Tuesday, otherwise by the next one.
🎉
Hi everyone! Thanks for your patience on this one.
As you can see the post operation on the ref node under members now accepts a proper model. https://github.com/microsoftgraph/msgraph-sdk-go/blob/32e95517554481b1846846df8198fdab79909f76/groups/item/members/ref/ref_request_builder.go#L126
Let us know if you need anything else.
awesome! Thanks for your help @baywet Going to do some testing this weekend and let you know if I notice anything
@baywet , I hope I'm just missing the obvious but I can't seem to find the method to create a struct of type ReferenceCreateable to pass to the Post method...can you help me out here.
models.NewReferenceCreate() ?
@baywet Thanks! 🙏 It's been almost a month and apparently I already forgot the convention, I was searching the repo for ReferenceCreateable
and didn't find anything. Just tried for ReferenceCreate
and no results either, I suspect GitHub hasn't indexed the new files/types as yet.
file search is usually much faster in my experience. (t on the repo main page, then reference_create)
Yup, that works much better though I would need to know the file name but at least it's something.
for this repo, the file names match the type name with the difference that types are UpperCamelCased and the file names snake_cased for future reference :)
Hello,
Using this example to attempt to add a member to an azure ad group.
I have this bit of code
I get below error
It seems to be this line specifically that is panicking https://github.com/microsoftgraph/msgraph-sdk-go/blob/main/groups/item/members/ref/ref_request_builder.go#L144
When debugging things I notice that the value for
res
Here isgithub.com/microsoft/kiota-abstractions-go/serialization.Parsable nil
which I believe explains the error I'm gettingIts possible I'm doing something horrible wrong, namely the add line
add, err := graphClient .GroupsById(&groupId).Members().Ref().Post(requestBody)
Am I using the.Ref()
portion properly?Oddly enough the user is being added to the group successfully. So the add is working minus the fatal panic 😄