2

in IBM Maximo 7.6.0.8 I would like to create PO from a PR using REST API and VBA (HTTP requests). My code is:

Dim PostData() As Byte
Dim IE As InternetExplorerMedium
Set IE = New InternetExplorerMedium

PostData = "~date=23-08-2018"
PostData = StrConv(PostData, vbFromUnicode)

myheader = myheader & "x-http-method-override: createPOsFromPR" & vbNewLine
myheader = myheader  & "Content-Type: application/json" & vbCrLf

IE.Navigate "https://host:port/maxrest/rest/mbo/pr/123", 0, "myIE", PostData, myheader

But I get Error 500. Authentication is not the problem. In general I would like to be albe to copy (assign) PR lines to POs and RFQs. Is this the way to do this? Does someone has working solution? Thanks!

Rhye
  • 25
  • 5
  • Is this really how the documentation recommends you interact with the API rather than xmlhttp? I would have expected a POST XHR. – QHarr Nov 20 '19 at 07:54
  • I have tried with POST XHR: ` PostData = "statusdate=23-08-2018" PostData = StrConv(PostData, vbFromUnicode) myheader = myheader & "x-http-method-override: createPOsFromPR" & vbNewLine myheader = myheader & "Content-Type: application/json;" objHTTP.Open "POST", "https://url/maxrest/rest/mbo/PR/123", False objHTTP.send (PostData)` Still not working. – Rhye Nov 20 '19 at 07:58
  • Hi, 1) What happened? 2) that is not how you would add headers to xhr. You would use .setrequestheader "myheader","pair" 3) Do you have the link to the documentation? Worth reading it and sharing here if possible. – QHarr Nov 20 '19 at 08:00
  • 1
    1) No result is produced, I should try con construct a better POST XHR I guess.. In other cases when I need HTTP POST this worked. 2) https://www.ibm.com/support/knowledgecenter/SSANHD_7.6.1/com.ibm.mif.doc/gp_intfrmwk/rest_api/c_rest_service_query.html This is not exactly the same but there is no clear documentation on this subject. Search for x-http-method-override – Rhye Nov 20 '19 at 08:06
  • There may be other methods I haven't seen :-) I will look at the documentation. – QHarr Nov 20 '19 at 08:07
  • 1
    I think you need .SetRequestHeader. Now, which of the following is the method you are trying to apply for creation? https://www.ibm.com/support/knowledgecenter/search/create%20po?scope=SSANHD_7.6.1 – QHarr Nov 20 '19 at 08:10
  • Yes, I did it with .setRequestHeader and I think my code before wasn't passing the header. So now I get Error 500 just like with InternetExplorer. In the search there is no documentation of my scenario. The closest think is the link I get posted. – Rhye Nov 20 '19 at 08:25
  • This link also is a good one: https://www.ibm.com/support/knowledgecenter/SSANHD_7.6.1/com.ibm.mif.doc/gp_intfrmwk/rest_api/c_rest_service_update.html – Rhye Nov 20 '19 at 08:29
  • Yes... I had seen that one but is that what you are trying to do? If so, your post body needs to look like that and that is what goes in the .send body – QHarr Nov 20 '19 at 08:45
  • The idea is the same but the action I want to perform is different - "createPOsFromPR" so the post body is also different. For the post pody I do reference to this page: https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/app/pr/PR.html search for "createPOsFromPR" – Rhye Nov 20 '19 at 09:35

1 Answers1

1

You could use the New REST API that allows you to directly call an automation script. You'd add the PR number and date as request parameters and use them in the script to call the PR.createPOsFromPR method.

Your call would look like this:

http://maximohost/maximo/oslc/script/genPOsScript?prnum=ABC&date=2019-11-21

You might want to add the site as param too because PR is a site level object.

You can see an example here: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_automation_scripts

JPTremblay
  • 900
  • 5
  • 8
  • Hello, thank you for the effort. The problem is that I don't have access to Maximo Admin Panel (I guess) where scripting happens. I cannot do changes to the system. – Rhye Nov 22 '19 at 07:34
  • 1
    @Rhye Unfortunately, it seems that the PR service doesn't expose a REST accessible Web Method for CreatePOsFromPR. You can get the allowed actions with a similar call: http://maximohost/maximo/oslc/os/mxpr?oslc.where=prnum="PR1000"&oslc.select=allowedactions Ref.: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_actions – JPTremblay Nov 25 '19 at 18:04
  • IBM has completely messed up their documentation system, breaking the helpful link you provided all these years ago. Do you happen to have a local copy stored somewhere? – Mast Feb 18 '23 at 13:08