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

PUT request fails even though json is correct #632

Open
rasmusolssony opened this issue Jun 7, 2023 · 3 comments
Open

PUT request fails even though json is correct #632

rasmusolssony opened this issue Jun 7, 2023 · 3 comments

Comments

@rasmusolssony
Copy link

	var s strings.Builder
	fmt.Fprintf(&s, `{"fields": {"customfield_11702": "%s"}}`, *targetVersion)
	data := s.String()
	req, err := client.NewRequest("PUT", "rest/api/latest/issue/ACCCONTROL-12365", data)

Im trying to do a simple PUT request but even though my json is correct it says there is something wrong with the body.

@andygrunwald
Copy link
Owner

Hey @rasmusolssony,
Why was this issue closed already?
Did you find the solution to it?
Would be cool if you could share your solution with the community.

@andygrunwald andygrunwald reopened this Jun 14, 2023
@rasmusolssony
Copy link
Author

I finally got it to work using this solution:

	var s strings.Builder
	fmt.Fprintf(&s, `{"fields": {"customfield_11702": "%s"}}`, *targetVersion)
	var data = strings.NewReader(s.String())

	req, err := client.NewRawRequest(http.MethodPut, url, data)

But I never got the NewRequest method to work and I'm not sure why the code in my original post didn't work either. Maybe an example or more detailed documentation about what type and format you are supposed to use could be handy.

@andygrunwald
Copy link
Owner

Thx. I will ensure to write something in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants