Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharingLink->getWebUrl() incorrectly mapped #1583

Closed
bsprengelmeijer opened this issue Sep 20, 2024 · 2 comments
Closed

SharingLink->getWebUrl() incorrectly mapped #1583

bsprengelmeijer opened this issue Sep 20, 2024 · 2 comments
Assignees
Labels
type:question An issue that's a question

Comments

@bsprengelmeijer
Copy link

bsprengelmeijer commented Sep 20, 2024

Describe the bug

When I request a sharing link, I can't access the webUrl because it is nested inside a link property, which is missing in getWebUrl()

This is my response
image

And this is the getWebUrl()

public function getWebUrl()
    {
        if (array_key_exists("webUrl", $this->_propDict)) {
            return $this->_propDict["webUrl"];
        } else {
            return null;
        }
    }

Expected behavior

->getWebUrl() returns the _propDict[link][weburl]

How to reproduce

$graphRequest = $this->graph->createRequest(Request::METHOD_POST, "/drives/{drive_id}/items/{microsoft_id}/createLink");

$graphRequest
       ->attachBody([
            'type'  => 'view',
            'scope' => 'anonymous',
       ])
       ->setReturnType(SharingLink::class);

/** @var SharingLink $sharingLink */
$sharingLink = $graphRequest->execute();

SDK Version

1.110.0

Latest version known to work for scenario above?

No response

Known Workarounds

Override sharingLink

class SharingLink extends \Microsoft\Graph\Model\SharingLink
{
    public function getLink(): ?string
    {
        if (array_key_exists('link', $this->_propDict) && array_key_exists('webUrl', $this->_propDict['link'])) {
            return $this->_propDict['link']['webUrl'];
        }

        return null;
    }
}

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@bsprengelmeijer bsprengelmeijer added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 20, 2024
@Ndiritu
Copy link
Contributor

Ndiritu commented Sep 30, 2024

Hi @bsprengelmeijer, thanks for reaching out.
The expected return type for this API call is a Permission object
By using this return type, I believe you should be able to do $response->getLink()->getWebUrl()

Please let me know if this works

@Ndiritu Ndiritu added type:question An issue that's a question status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 30, 2024
@Ndiritu Ndiritu closed this as completed Sep 30, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Sep 30, 2024
@Ndiritu Ndiritu self-assigned this Sep 30, 2024
@bsprengelmeijer
Copy link
Author

Hi @Ndiritu, the Permission object is working thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

2 participants