Message 1 of 6
		
			
				
					
						
							REST API: Creating binary workspace items
						
					
					
				
			
		
	
			
	
	
	
	
	
			Not applicable
		
			
    
	
		
		
		11-19-2015
	
		
		11:47 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
    - Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report
 
I am trying to figure out how to add images to an item I'm creating via the API from VBA (in SolidWorks). I'm using this blog post (specifically, the approach using WinHttp.WinHttpRequest.5.1) to understand how to post a binary file to an API with VBA; however, there seems to be several things that need to be changed to get this approach to work with PLM 360, and I'm not sure what they all are.
Here are the main things that are puzzling me at the moment:
- The PLM 360 documentation seems to indicate that one request is being sent in two parts, but I don't understand how to do that in VBA.
 - The code in the blog post surrounds the binary file with boundaries. Is that necessary?
 - The code in the blog post includes the Content-Disposition and a few other things in the binary portion. Is this necessary for PLM 3660?
 - The caveat to the pvToByteArray function is confusing to me. I understand that it is converting back to a byte array the string containing the file data, but if #3 above is not necessary in PLM 360, is it necessary to convert the file to a string and then back to a binary blob, or does that result in it being possible to pass baBuffer without failure?
 - How do I include the rest of the information in the request for creating the item? I suppose this is somewhat related to #1 above.
 
To say the least, I really have no idea what I'm doing here, and I'm not sure if this is the right place to ask these questions or if it would be better to ask them of some place more familiar with SolidWorks' VBA, but I would greatly appreciate any help anyone can provide.