Giter Site home page Giter Site logo

Comments (4)

hidden-69 avatar hidden-69 commented on July 18, 2024

When I add the attachment, it returns a 404 bad request, when I remove the attachment part it works fine.
$Request=@"
{
"Message": {
"Subject": $(Escape-StringToJson $Subject),
"Body": {
"ContentType": "HTML",
"Content": $(Escape-StringToJson $Message)
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "$Recipient"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "attachment.txt",
"contentType": "text/plain",
"contentBytes": "SGVsbG8gV29ybGQh"
}
]

},
"SaveToSentItems": "$(if($SaveToSentItems){"true"}else{"false"})"
}
"@

from aadinternals.

hidden-69 avatar hidden-69 commented on July 18, 2024

Also, any idea why this doesn't work with a access token and does work with a app registration in Graph Explorer Developer?

$url="https://graph.microsoft.com/beta/me/mailFolders/inbox/messageRules"    
Invoke-RestMethod -UseBasicParsing -Uri $Url -Method GET -Headers @{Authorization = "Bearer $($attributes.EXO)"} -Debug
        
VERBOSE: GET https://graph.microsoft.com/beta/me/mailFolders/inbox/messageRules with 0-byte payload
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:5 char:9
+         Invoke-RestMethod -UseBasicParsing -Uri $Url -Method GET -Hea ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 

from aadinternals.

hidden-69 avatar hidden-69 commented on July 18, 2024

Or this, any help would be appreciated :)

`$headers = @{
"Authorization" = "Bearer $($attributes.EXO)"
"Accept" = "gzip, deflate, br"
"Accept-Encoding" = "gzip, deflate, br"
"Accept-Language" = "en-US,en;q=0.9"
}

    $url="https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messagerules"    


    Invoke-RestMethod -UseBasicParsing -Uri $Url -Method GET -Headers $headers

`

from aadinternals.

NestoriSyynimaa avatar NestoriSyynimaa commented on July 18, 2024

https://graph.microsoft.com requires that the client you are using has permissions to the API you're calling. You can check the scp claim from the access token to see the permissions with Read-AADIntAccessToken or at https://aka.ms/JWT

What comes to sending attachments, I haven't tried that in years so can't tell what's wrong in your code. Try to double-check the attribute names and structure (should the first letter be capital etc.).

from aadinternals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.