Bug 1683723

Summary: unable to create or edit a service from the api with "Picture expected, got Hash" error
Product: Red Hat CloudForms Management Engine Reporter: Felix Dewaleyne <fdewaley>
Component: APIAssignee: drew uhlmann <duhlmann>
Status: CLOSED CURRENTRELEASE QA Contact: Parthvi Vala <pvala>
Severity: low Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: low    
Version: 5.9.7CC: dmetzger, fdewaley, mshriver, obarenbo, simaishi, yrudman
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.11.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: 5.11.0.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1702479 (view as bug list) Environment:
Last Closed: 2019-12-13 15:00:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1702479    

Description Felix Dewaleyne 2019-02-27 16:14:52 UTC
Description of problem:
When trying to create a service through the api, the command fails with  a bad request error - the error indicates a hash was received instead of a picture.

Version-Release number of selected component (if applicable):
5.9.7

How reproducible:
all the time

Steps to Reproduce:
1. upload a picture using curl (encode it in base64)
2. create a service 
3. edit the service through the api to use a different picture

Actual results:
curl -k --user admin:smartvm -X POST -d @photo2.crl -H "Accept: application/json" -g "https://IP//api/service_templates/101000000000023" | python -m json.tool 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   474    0   160  100   314    114    225  0:00:01  0:00:01 --:--:--   225
{
    "error": {
        "kind": "bad_request",
        "klass": "Api::BadRequestError",
        "message": "Could not update Service Template - Picture(#129832020) expected, got Hash(#3879260)"
    }
}


Expected results:
able to use the uploaded picture to edit the service

Additional info:
similar issue happens when trying to create the service with a picture from the api, but the most information I have around this issue is on edition.

Comment 3 Parthvi Vala 2019-03-01 07:18:19 UTC
@Mike Sure, I can modify the method to include a picture.
@Felix I passed `picture` while creating a service template, and got an error similar to yours, can you confirm if the query looks okay?

POST /api/service_templates
Query: {
	"name": "item_EfN40",
	"prov_type": "generic",
	"service_template_catalog_id": "7",
	"config_info": {
		"retirement": {
			"fqname": "/Service/Retirement/StateMachines/ServiceRetirement/Default",
			"dialog_id": "8"
		},
		"provision": {
			"fqname": "/Service/Provisioning/StateMachines/ServiceProvision_Template/CatalogItemInitialization",
			"dialog_id": "8"
		}
	},
	"service_type": "atomic",
	"display": true,
	"description": "mycatalogEfN40",
	"picture": {
		"content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAADUlEQVQIHWNgYGCwBQAAQgA+3N0+xQAAAABJRU5ErkJggg==",
		"extension": "jpg"
	}
}

Response: {
  "error": {
    "kind": "bad_request",
    "message": "Could not create Service Template - Picture(#124586900) expected, got Hash(#15233320)",
    "klass": "Api::BadRequestError"
  }
}

Comment 4 Felix Dewaleyne 2019-03-01 09:38:19 UTC
yes, that looks correct - the content being a base64 encoded picture.

Comment 5 drew uhlmann 2019-04-23 15:01:56 UTC
https://github.com/ManageIQ/manageiq/pull/18674

Comment 7 Satoe Imaishi 2019-04-26 15:15:17 UTC
https://github.com/ManageIQ/manageiq/pull/18689

Comment 8 Parthvi Vala 2019-05-02 15:38:41 UTC
FIXED. Verified on 5.11.0.2.20190430174828_0e34dea.