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

Use -ContentType parameter in Invoke-WebRequest #19

Closed
wants to merge 1 commit into from

Conversation

lukhase
Copy link

@lukhase lukhase commented Dec 16, 2015

The Invoke-WebRequest command offers a contenttype parameter. Setting
the content type using the normal headers does not work for me

The Invoke-WebRequest command offers a contenttype parameter. Setting
the content type using the normal headers does not work for me
@replicaJunction
Copy link
Collaborator

Hi Lukas,

Thanks for your pull request. Could you provide some more information about what's going on? In every example I know of, the JIRA API that PSJira works with expects the body of a Web request to be in JSON format, and the -Headers parameter has been working as expected so far. I'd like to understand why it's not working correctly before making the change. Specifically, here are a few things that will help get started:

  • What version of Windows are you using?
  • What version of PowerShell are you using?
  • What function and parameters are you running? Are you using Invoke-JiraMethod directly, or are you having this problem with a function like Get-JiraIssue?
  • Do you receive any sort of error message, or does the function appear to complete successfully?

Thanks,
replica

@lukhase
Copy link
Author

lukhase commented Dec 17, 2015

Hi,
I am having this issue on Windows 8.

PS C:\> $PSVersionTable.PSVersion
Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1

E.g. if a run New-JiraSession without any parameters, after entering the credentials I get the error. The unmodified New-JiraSession script does not show the error message itself, because $webResponse is null
However, if I just output the exception, you can see the error

Invoke-WebRequest : The 'Content-Type' header must be modified using the appropriate property or method.
Parameter name: name
At C:\Users\xxx\Documents\WindowsPowerShell\Modules\psjira\Functions\New-JiraSession.ps1:65 char:28
+             $webResponse = Invoke-WebRequest -Uri $uri -Headers $headers -Method ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I could not find another command that is affected by this issue, so maybe the changes in Invoke-JiraMethod are not necessary at all. However, I think that may still be a good idea, to be on the safe side. I have no explanation at the moment, why setting the contenttype there directly using the headers argument does work, but raises the error in new-jirasession

@replicaJunction
Copy link
Collaborator

Hey, I apologize for the delay in getting back to you here. Are you still running into this issue?

If so, I'll update the test suite and have you double-check one more time that your commit is working correctly.

@lukhase
Copy link
Author

lukhase commented Apr 4, 2016

Hi, no worries regarding the delay
I checked today and I still have the same issues with the code from this repo while everything works fine with my changes. No idea why I'm the online one who has these problems...
Sry, I did not really think about the test suite :/ Would be really great if you could update it
For sure I can double-check the changes afterwards

@replicaJunction
Copy link
Collaborator

Hah, I think I may have goofed up my GitHub. I'm still getting used to working with PR's on this site.

It looks like the changes I made aren't showing here in this pull request, but they appear in a new branch on the main page, pr/19. Could you download that branch (latest commit at the moment is 510cce6) and make sure that's working correctly for you? If so, I can merge the changes.

@lukhase
Copy link
Author

lukhase commented Apr 28, 2016

Yep, it works for me now! Thanks
To be sure I tested the right version, I used this one for the tests:
https://github.com/replicaJunction/PSJira/tree/510cce6c392aae5ddc8f0a03ba543611927f0d0c

@lipkau lipkau self-assigned this Jun 8, 2017
@lipkau lipkau added this to the v1.3 milestone Jun 8, 2017
@lipkau lipkau requested review from replicaJunction and Dejulia489 and removed request for replicaJunction and Dejulia489 June 8, 2017 17:20
@lipkau lipkau reopened this Jun 8, 2017
@lipkau lipkau closed this Jun 8, 2017
@lipkau lipkau removed this from the v1.3 milestone Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants